
Retro-Progress-3 – A platformer sprite would not go far without variable jump
This is how I did variable jump for my #deadclones game. Vertical movement is a y++ loop that breaks on collision.
Again something I have learnt first from Heartbeast, Shaun and Zach.
My code is a bit heavy as I wanted to have fine controls on the jump parameters so that I would be able to tweak everything later on. For instance, bouncing coefficients are different for the ceiling, the floor, the wall and what happens on collision is managed outside the movement code so that it can be specific to each object. While ascending, I used additive acceleration and friction coefficient because I wanted the jump to mimic the run mechanism with a friction coefficient (gravity is only applied after max jump is reached).
Anyhow, I would strongly advise anyone unsure about it to have some specific separated collision and movement scripts. This allows to manage all moving items (projectiles, pickup, player, enemeis…) with a consistent framework and anytime you want to update how collision behave you just have to tweak one script for it to be taken into account everywhere in your game.
On platformer movements, let me just point you out to:
https://shaunspalding.co.uk/
https://www.heartgamedev.com/
https://zackbellgames.com/tag/game-maker/
Sharing is how great games are made