This is a simple flowchart of how my 2D platformer controller works. First and importantly i have to see if the bottom part of my controller have contacted the ground. If there is contact with the ground, my boolean variables, grounded and jump is set to true.
I would only allow the player to move and jump when they are on the ground. And when the arrow key is released, the player will decelerate. And when the jump button is pressed, both my boolean variables will be set to false, preventing the player from multi-jumping.
The acceleration and deceleration does not apply when the player is in the air as in reality, no one can do that and what is affect the speed of the human when they are in the air is air resistance, which will be a future add-ons to my 2D platformer controller.
I would only allow the player to move and jump when they are on the ground. And when the arrow key is released, the player will decelerate. And when the jump button is pressed, both my boolean variables will be set to false, preventing the player from multi-jumping.
The acceleration and deceleration does not apply when the player is in the air as in reality, no one can do that and what is affect the speed of the human when they are in the air is air resistance, which will be a future add-ons to my 2D platformer controller.