Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

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 -
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.

1 decade ago by jackrugile

If I am understanding what you are trying to do correctly, I think all you have to do is this:

if(this.standing && ig.input.state("jump")) {
    this.vel.y = -this.jump;
}

Then, the player should jump each time he lands on the ground, as long as you keep the jump key pressed.

1 decade ago by Silent

Nice! I'm a bit disappointed that I didn't figure it out by myself, but at least I got it working now.

Thank you very much :)

1 decade ago by jackrugile

Glad it worked! I recently finished that book too and have been loving Impact, good luck with your game.
Page 1 of 1
« first « previous next › last »