Double jumping is a staple in many games. It’s especially common in many platformers and Metroidvanias. Now, if you’re like me starting out, I had no idea where to start, so today we’ll give you a breakdown of how to create your own double jump mechanic using the Pico-8.

The Physics Of The World

Every game world that has a double jump usually has some physics calculations associated with it. I promise we won’t be going too deep into Physics or Math. The most important concepts to understand here are gravity, time, velocity, and vectors. Let’s start with gravity and time.

Gravity And Time 

Gravity is acting upon objects in your game over time. In most games, this would happen during the Physics process, in Pico-8, that’s during the update loop. Why? Because the update loop runs every frame; this is your time in the game.

So, we apply gravity every frame. Here’s an example in code and the result you can see above, as the character continues to fall to the bottom of the screen.

function move_player(p)
local mspd = p.mvspd
if (btn(0)) then p.dx=-mspd end
if (btn(1)) then p.dx=mspd end
jump function
process gravity
apply physics
p.x += p.dx
p.y += p.dy
p.dx = 0

Note, we use our property dy to modify the player’s y-value. The only reason we don’t have the character falling forever is as a result of our adding bounds check to prevent that.

Now, with physics in place, we can create our own jumping and double jump mechanics. 


A jump is just a burst force in the opposite direction of the gravity; it is also triggered on demand. So, we need to add force in the opposite direction and allow the player to perform the action twice.

Here’s our code example and the result.

function jump(p)
jump processing
if (btnp(2)
and p.jumpcount < 1) then
resets count at floor level
if (p.y >= 119) then
p.jumpcount = 0

As you can see, we add a new property to check the jump count of the player, as long as it is less than 1, the player can jump again. And, the jump is force in the opposite direction of the gravity we set.

Tada! You have a double jump mechanic in your game. This may have been written in the Pico-8, but the same code applies to just about any game you make in the 2D space, and possibly 3D.

This is a simple example, so you may have a more complicated checks and balances in your own game to accomodate. In the meantime, this will get you started and stay tuned!

%d bloggers like this: