Hello everyone,

I made a little game so far, I made walls, I am 17 and I struggled a lot with walls

basically what I did is I programmed a slime which is my main character to move with awsd with a speed of 5
this is what my code looks like for the slime:

category:KEY DOWN:
if(key === “w”)
{this.y -= 5;}
if(key === “s”)
{this.y += 5;}
if(key === “d”)
{this.x += 5;}
if(key === “a”)
{this.x -= 5;}

After struggling with the walls for entire 4 hours, I didn’t give up. AND THIS IS HOW THE CODE LOOKS FOR THE WALLS:

category:UPDATE:
if(this.hits(slime)){slime.y += 5;}


this is the code for the up wall.

I HOPE THIS HELPED, I still can’t believe I did it!

4 Likes

Hey @Z_Dia_Z, welcome to the forums!
Walls are hard to program, it’s good to hear that you got it working though, :tada: congrats!

2 Likes

it’s nice to hear that you got it working and I hope it helps new people like you build games.

1 Like

Wow 4 hours to make the wall work huh?

1 Like