Game Development Reference
In-Depth Information
There are four different states to jump, as follows:
GROUNDED : In this state, the player is standing on a platform.
FALLING : In this state, the player is falling down.
JUMP_RISING : In this state, the player has initiated a jump and is still rising.
The maximum jump height has not been reached.
JUMP_FALLING : In this state, the player is falling down after a previously
initiated jump. This state is reached either by jumping as long as possible or
by releasing the jump key earlier than that.
The state to jump is stored in jumpState . There is a minimum and maximum jump
time defined by the constants JUMP_TIME_MIN and JUMP_TIME_MAX . These time
limits and the jump power affects the resulting possible minimum and maximum
jump heights. A minimum jump is enforced on the player whenever the jump key is
released before the time defined in JUMP_TIME_MIN .
The currently elapsed jump time is accumulated in timeJumping and is reset on
every new jump. There is a third constant JUMP_TIME_OFFSET_FLYING that is used to
let the elapsed jump time start at a certain time, which effectively shortens the overall
height of such jumps. This is used for the multijump power-up effect of the feather
item. It allows the bunny head to fly by rapidly jumping repeatedly. A multijump
can only be executed when the bunny head is in midair. A shorter jump time for
multijumps makes it more difficult for the player to handle them, which adds a neat
detail to the gameplay feeling.
This is all done inside the overridden updateMotionY() method. Notice that the
original method of updateMotionY() from AbstractGameObject is also called
whenever an actual motion needs to happen, which is always the case when the
player is not in the GROUNDED jump state.
 
Search WWH ::




Custom Search