1 decade ago by Silent
Hey guys.
I'm following "Introducing HTML5 Game Development", and I got my entity to jump. The problem is that it will only jump one time, so in order for it to jump again I have to release my jump key and hit it again. Also, the jump feels a little bit unresponsive at times(sometimes when I hit jump again right after it landed, it won't jump again).
I would like to implement a MapleStory-kind of jump - where you will continue jumping for as long as you keep the jump key presses. I would imagine the pseudo-code would look like this -
However, I'm not sure how to convert it to JS. Here's what I have so far -
This seems to be exactly what I need, but it doesn't work the way I expect it to.
Help please?
Thanks in advance.
I'm following "Introducing HTML5 Game Development", and I got my entity to jump. The problem is that it will only jump one time, so in order for it to jump again I have to release my jump key and hit it again. Also, the jump feels a little bit unresponsive at times(sometimes when I hit jump again right after it landed, it won't jump again).
I would like to implement a MapleStory-kind of jump - where you will continue jumping for as long as you keep the jump key presses. I would imagine the pseudo-code would look like this -
if(standing && jumpKeyPressed) { jump(); }
However, I'm not sure how to convert it to JS. Here's what I have so far -
if(this.standing && ig.input.pressed("jump")) { this.vel.y = -this.jump; }
This seems to be exactly what I need, but it doesn't work the way I expect it to.
Help please?
Thanks in advance.