Back to Forum
Mario jump issues
gmdisnuts posted 4 years ago

When you keep tapping jump he just flies around. Is there a fix that he can only jump when he's on a platform? Someone commented to add this command to prevent from holding the jump key. Just need to fix when tapping the jump key.if (event.repeat) { return }

g
gmdisnuts posted 4 years ago

I'm still pretty new at this but I think I'm getting close?

if (keys.up.pressed = true && player.position <= platform({      })  ) {    player.velocity.y -= 25   }

g
gmdisnuts posted 4 years ago
case 38:      console.log('up')          if (allowJump) {        allowJump = false;                player.velocity.y -= 25                setTimeout(function(){           allowJump = true;        },500);                break           }

This did solve my issue for the time being. Probably some sort of collision detection would be better. Still new at this but this does get the job done for the time being.

EDIT: let allowJump = true;

put that above addEventListener I'm sure there's a much better way to do this but it worked.

Want to participate?

Create a free Chris Courses account to begin

Providing the lift to launch your development career

© 2026 Chris Courses. All rights reserved.