What is the best way to add a jumping mechanic to a shape in p5js
1 Like
When a key is pressed, and that key is the space bar, set the object’s velocity to some negative value. You might also want to check your shape is standing on solid ground.
Each time you simulate the object’s motion, add it’s acceleration (probably a positive constant) to its velocity, and its velocity to its position.
Then just make sure you’re drawing the shape at its position.