Module m.platformer
Wrapper for the physics and behaviour involved in creating a platformer game
Functions
create (collision_hashes) | Create a platformer game logic wrapper. |
instance.right (velocity) | Move the game object right by setting horizontal velocity |
instance.move (velocity) | Move the game object by setting its velocity |
instance.stop () | Stop horizontal movement by setting the velocity.x component to zero |
instance.jump (power, allow_double_jump, allow_wall_jump) | Try to make the game object jump. |
instance.abort_jump (reduction) | Abort a jump by "cutting it short" |
instance.is_jumping () | Check if this object is jumping |
instance.is_falling () | Check if this object is falling |
instance.on_message (message_id, message) | Forward any on_message calls here to resolve physics collisions |
instance.update (dt) | Call this every frame to update the platformer physics |
Functions
- create (collision_hashes)
-
Create a platformer game logic wrapper. This will provide all the functionality
to control a game object in a platformer game. The functions will operate on
the game object attached to the script calling the functions.
Parameters:
- collision_hashes Table with hashes for the collision groups that prevents movement and where collisions should be resolved
- instance.right (velocity)
-
Move the game object right by setting horizontal velocity
Parameters:
- velocity Horizontal velocity
- instance.move (velocity)
-
Move the game object by setting its velocity
Parameters:
- velocity Velocity as a vector3
- instance.stop ()
- Stop horizontal movement by setting the velocity.x component to zero
- instance.jump (power, allow_double_jump, allow_wall_jump)
-
Try to make the game object jump.
Parameters:
- power The power of the jump (ie how high)
- allow_double_jump True if double-jump should be allowed
- allow_wall_jump True if wall-jump should be allowed
- instance.abort_jump (reduction)
-
Abort a jump by "cutting it short"
Parameters:
- reduction The amount to reduce the vertical speed (default 0.5)
- instance.is_jumping ()
-
Check if this object is jumping
Returns:
-
true if jumping
- instance.is_falling ()
-
Check if this object is falling
Returns:
-
true if falling
- instance.on_message (message_id, message)
-
Forward any on_message calls here to resolve physics collisions
Parameters:
- message_id
- message
- instance.update (dt)
-
Call this every frame to update the platformer physics
Parameters:
- dt