gma.moveable¶
Provides functionality for a moveable shape
Package
gma/entities/moveable
Inheritance chain
Descendants
gma.character,gma.enemy,gma.platformEnemy,gma.jumpingEnemy,gma.patrolEnemy
Tags¶
shape, moveable
Properties¶
Inherited from gma.shapes.rectangle
points, edges, width, height, depth, z, x, y, centre, left, right, top, bottom, yOffset, xOffset, type, alive, solid, tags
yState
Flag saying whether character is jumping, falling or neither
Type
Default
xState
Flag saying whether character is going left, right or neither
Type
Default
lastXState
Flag saying what direction character was going last before becoming horizontally still
Type
Default
self.xState
velocity
Number representing how fast the character is moving vertically
Type
Number
Default
0
jumpVelocity
Number representing the initial velocity of a jump
Type
Number
Default
4
Methods¶
Inherited from gma.shapes.rectangle
setPointsAndEdges, setCentre, setBottomLeft, xOf, yOf, toString, collided, collided__deathtouch
- getMovement (moveAmount) -> Amount to move as [x, y]
- Looks at the character’s state and determines how far it should moveThis result will then be checked for collisions and may be modifiedIf the character is jumping :- Keep going up if haven’t reached targetY 
- else set vertical state to FALLING 
 If we’re falling, then we go downIf horizontal state is not STILL, then we add horizontal movement.Parameters moveAmount Number The amount the character should move 
- animate (delta, manager)
- Changes character’s position according to it’s stateFirst it asks getMovement how much we should moveThen it determines how far we can move given the environmentIt will then change the state of the character accordinglyIt will then determine if the character is on top of groundand set vertical state to FALLING or STILL accordinglyParameters delta Number Time since last animation manager 
- findGround (manager)
- Finds any ground the character is on and changes state accordingly - Parameters - manager 
- updatePositions (vector)
- Changes it’s position, centre, points and edges. - Parameters - vector - [x, y] - Vector representing the amount character can move 
- getRotation ( ) -> Number
- Gets rotation in radians 
- kill ( )
- Kills the entity. Should be overwritten to do something useful.