-
Notifications
You must be signed in to change notification settings - Fork 9
Player Movement
Player Movement is updated and extended to both normalise diagonal movement and implement a dodge button.
Diagonal movement is implemented when the player presses two keys simultaneously (KeyboardPlayerInputComponent). The player will move at the same speed as the four-directional walking (Vector2Utils).
The dodge button (assigned to the space bar) allows the player to move faster and further than regular walking (Vector2Utils). It has a three-second cool-down. The player can dodge up, down, left and right, which is based on the previous direction the player is moving (KeyboardPlayerInputComponent). After dodging, the player is given 0.15 seconds of immunity (PlayerActions).
KeyboardPlayerInputComponent class:
-
diagonal
: Implements the diagonal movement of the player by evaluating which keys the player is pressing and determining which direction the player is wanting to go. This is then scaled to the relevant vector (eg.UP
). -
triggerDodgeEvent
: Implements movement of the player in the direction specified for 200 ms (using java.util.TimerTask and java.util.Timer classes) and applies temporary immunity. -
dodge
: Implements three-second cool-down using java.util.TimerTask and java.util.Timer classes.
Vector2Utils class:
-
DODGE_UP
/DODGE_LEFT
/DODGE_DOWN
/DODGE_RIGHT
: Vectors which change speed from 1 to 5, therefore allowing the player to 'dodge'.
PlayerActions class:
-
dodged
: Changes immunity status of the player, implemented intriggerDodgeEvent
.
-
Implement animation of player whilst dodging (such as rolling animation)
-
During dodge, prohibit player from being able to attack during its time period (0.15 seconds)
Here is the UMl Diagram for Player Movement component.
Escape Earth Game
Interaction Controller and Interactable Components
Game and Entity Configuration Files
Loading Game Configuration Files