Challenge: Developing a Video Game in one Week — Day 1

Rick
2 min readJul 25, 2023

--

Revisiting Unity2D and C#

Before you read

It’s been a long time since I’ve made and published a videogame. So in order to make my ADHD self follow through with developing a playable and publishable game I challenged myself to do it in one week. It’s not impossible nor too hard but it is the firs time I do something like this. So for the main Idea I’m just going to try and replicate the N++ video game, at least some aspects which are parkour, hostile NPCs, coins, etc.

from TV Tropes

Day 1

For day 1 I just wanted to make the basic movement mechanics which are running, jumping and wall jumping and sliding.

Assets

I found some pretty cool assets for the player in itch.io by ZeggyGames, It’s probably the most useful asset pack for a makeshift player even if you have no art skills like me.

Running

This is pretty straight forward, if you have some experience using Unity you just need to get the Player input and set the Rigidbody2D velocity.

private float horizontal;

void Update(){
horizontal = Input.GetAxisRaw("Horizontal");
animator.SetFloat("run", Mathf.Abs(horizontal));
}

void FixedUpdate(){
rb.velocity = new Vector2(horizontal, 0 ) * Speed * Time.deltaTime;
}

Jumping

Jumping is pretty easy and still every time I try to do it first try I always fail. Anyway there are several ways to do it but in my case I tried to keep in mind the jumping animations. Because of this I may have overused the amount of boolean variables I really needed.


public float JumpForce;
public LayerMask groundLayer;
public Transform groundCheck;
public bool grounded;
public bool JumpBtn;
public float gravityScale = 5;

void Update(){
animator.SetBool("grounded", grounded);

if(grounded){
if(Input.GetKeyDown(KeyCode.Space)){
grounded = false;
JumpBtn = true;
animator.SetTrigger("jump");
}
}

}

void FixedUpdate(){

grounded = Physics2D.Raycast(groundCheck.position, Vector2.down, 0.2f, groundLayer.value);
if(JumpBtn){
JumpBtn = false;
rb.AddForce(Vector2.up * JumpForce, ForceMode2D.Impulse);
rb.AddForce(Physics.gravity * (gravityScale - 1) * rb.mass);
}
}

When I finish this challenge I’ll make sure to include a GitHub repo. for now it’s looking like this.

--

--

Rick
Rick

Written by Rick

I blog about everything I learn, Digital Image Processing, Data Science, IoT, Videogame design and much more :)

No responses yet