This class provides properties that represent the movement state of an entity as well as functions for changing these states and functions for updating the entity’s position.
Although Gamma is rendered in 3D all entities move in 2D. As a result of this, the movement state only needs to keep track of the entities’ horizontal and vertical movement.
When an entity starts jumping, it will use jumpVelocity to determine what vertical velocity the entity should start with. For the rest of the time the entity is in the air, it’s vertical velocity is held by velocity, which is changed by getMovement.
For example, gma.character provides the functions move and jump which when called through combination with keybindings will change the entities movement states and allow the player to control the entity.
To change the position of an entity according to it’s vertical and horizontal state, gma.moveable provides animate and getMovement. The getMovement function returns a movement vector calculated from the entity’s current vertical and horizontal state and is used by the animate function, which in turn, is called as part of the Game Loop.
The animate function does the following:
The kill method will set alive to false and set xState to STILL. This ensures the entity won’t continue moving after being “killed”, and removeDead will become aware that this entity should be removed.
The getRotation is purely for changing the visual representation of an entity. When called, it will look at the state of the entity and determine which direction it should be facing and return a number representing how far around the y-axis the entity should be rotated.