stckpete
stckpete

Reputation: 571

Jumping character in HTML5 game code

To make the player jump, I often see the code snippet below. My question is, what is the purpose of using a timer? I assume it prevents double jumping. Can anyone explain how this works?

   if (jumpButton.isDown && this.body.onFloor() && this.game.time.now > jumpTimer) {}

Many thanks

Upvotes: 1

Views: 137

Answers (1)

John Pavek
John Pavek

Reputation: 2665

Normally this is used to prevent double jump, or spamming jump. Some games especially first person shooter style try to prevent "bunny hopping" which has a history of being seen as a poor play style.

Upvotes: 1

Related Questions