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!