Here is an example of a side scrolling game where the hero jumps over endless platforms.
Customization
This game is not using a tilemap, so you can make the game as big as you like. You might also want to have the player shoot projectiles at enemies, perhaps jump over other obstacles.
You can also play the game here: https://cosmoscowboy.github.io/platform-jumper/
and also fork the repository: https://github.com/cosmoscowboy/platform-jumper
Have fun customizing the game. Please let me know if you have any questions on the game mechanics, and ways of improving it.
3 Likes
What math do you use for collisions?
I donât use any math.
At the start of the game a place sprites until the width of the screen and place the player on top of one. I then set the ay of the player to a positive value so that it falls. In the method âcheckPlayerâ I check if the player is overlapping one of the âplatformâ sprites, and if so, move the player up one pixel at time until the bottom of the player is less the the platform it hits. At this point, I set the vy & ay to zero so the player is no longer falling. When the player jumps, I see ay again so the player eventually falls again.
2 Likes
This maybe by design, Iâm not sure. I noticed you can wait long enough to let the player begin to fall between two platforms and when it seems it should irrevocably fall down, you can jump up âmid airâ.