Custom Platformer Movement

Hello!

I was trying to replicate the platformer behavior using purely events and not using the simulate platformer function. However, I couldn’t figure out the jumping mechanic.

Would anyone please help me on how to make a simple basic platformer using only events? Would be really appreciated. :slight_smile:

I don’t know how you are doing it, so it’s hard to tell. The common way is, since you apply a positive Y-acceleration to make the player Y-speed increase and fall, when you jump set a negative Y-speed, to make it automatically get a “force” upwards.

Thank you but it’s so hard for me to grasp the coding part. How would you code something like Mario jumping?

So, if you really want to code everything yourself, you’re going to need a timer of some sort, a control loop, an idea of the pixel scale of your screen, and a bunch of variables.
The variables store values such as if you are/are not jumping, your x position, your y position, whether or not you are standing, something to account for gravity, etc.
The timer will provide you with a specific rate at which code can by applied at, or “stepped” through.
The control loop will keep everything going, stringing each timer-ticked moment, being fed variables such as where the player is and where they need to be going, and spit out the desired effect.
For example, consider that mario has just jumped off the platform…
the timer will tick maybe every 100 ms (10 times a second) so in the next tenth of a second, mario will have his X height variable raised, his jumping variable set to on, and either a timer or set number of steps will start counting down for when later on he needs to stop rising and start failing. At this point the sprite’s height is updated, giving the impression he is rising into the air, the sprite’s animation changes to show he is leaping, and if necessary he can be moved sideways as well to show that he wasn’t jumping straight up. The amount of pixels moved each time is small, less for slower moving objects, more for faster moving objects. 1/10th of a second later, all the same calculations are made, and when these all string together over time we create the illusion of life and motion.
Regardless of what language you program in, that’s how it would be done.