Module: PseudoGame.game.Player

Class that represents a game's player

Functions

PseudoGame.game.Player:new ([options[, style=nil]]) the constructor for a player that can handle collisions (without relying on the game's internals)
PseudoGame.game.Player:reset_swap_cooldown () reset the swap cooldown to show swap blinking effect (should be called in onCursorSwap when using the "real" player)
PseudoGame.game.Player:swap () swap the player while respecting collisions properly (only works when using a custom collision handler)
PseudoGame.game.Player:update (frametime[, move], focus[, swap[, collide_collection]]) update the players position while handling collisions as well as swap

Tables

pseudogame.game.player.pos
pseudogame.game.player.last_pos

Fields

pseudogame.game.player.style
pseudogame.game.player.angle
pseudogame.game.player.last_angle
pseudogame.game.player.movement_dir
pseudogame.game.player.speed
pseudogame.game.player.swap_blink_time
pseudogame.game.player.swap_cooldown_time
pseudogame.game.player.just_swapped
pseudogame.game.player.options
pseudogame.game.player.dead
pseudogame.game.player.radius
pseudogame.game.player.polygon


Functions

🔗 PseudoGame.game.Player:new ([options[, style=nil]])
the constructor for a player that can handle collisions (without relying on the game's internals)

Parameters:

Name Type(s) Description Default value
options Optional table some options for the player Undefined
collision_handler Optional function the collision system to use (nil will make it use the real player, so you'll have to draw cws with collision) nil
reverse Optional bool reverse the player (obviously this only works with a custom collision handler) false
radius Optional number overwrite the default radius the player moves on (obviously this only works with a custom collision handler) Undefined
style Optional Style the style to use level_style

Returns:

    Player
🔗 PseudoGame.game.Player:reset_swap_cooldown ()
reset the swap cooldown to show swap blinking effect (should be called in onCursorSwap when using the "real" player)
🔗 PseudoGame.game.Player:swap ()
swap the player while respecting collisions properly (only works when using a custom collision handler)
🔗 PseudoGame.game.Player:update (frametime[, move], focus[, swap[, collide_collection]])
update the players position while handling collisions as well as swap

Parameters:

Name Type(s) Description
frametime number the time in 1/60s that passed since the last call of this function
move Optional number the current movement direction, so either -1, 0 or 1 (only required when using a custom collision handler)
focus bool true if the player is focusing, false otherwise
swap Optional bool true if the swap key is pressed, false otherwise (only required when using a custom collision handler)
collide_collection Optional PolygonCollection the collection of polygons the player should collide with (only required when using a custom collision handler)

Tables

🔗 pseudogame.game.player.pos

Fields:

Name Type(s) Description
pos table the current position of the player (formatted like this: {x, y})
🔗 pseudogame.game.player.last_pos

Fields:

Name Type(s) Description
last_pos table the position the player had in the last tick (formatted like this: {x, y})

Fields

🔗 pseudogame.game.player.style
Name Type(s) Description
style Style the style the player is using
🔗 pseudogame.game.player.angle
Name Type(s) Description
the number player's current angle
🔗 pseudogame.game.player.last_angle
Name Type(s) Description
the number angle the player had in the last tick
🔗 pseudogame.game.player.movement_dir
Name Type(s) Description
the number current movement direction
🔗 pseudogame.game.player.speed
Name Type(s) Description
the number current movement speed
🔗 pseudogame.game.player.swap_blink_time
Name Type(s) Description
a number number that indicates the current state of the swap blinking animation (the current blink hue is swapblinktime * 36)
🔗 pseudogame.game.player.swap_cooldown_time
Name Type(s) Description
the number time in 1/60s the player has until it can swap again after swapping
🔗 pseudogame.game.player.just_swapped
Name Type(s) Description
this bool field is true if the player swapped this tick, it's false otherwise
🔗 pseudogame.game.player.options
Name Type(s) Description
the table player's options
🔗 pseudogame.game.player.dead
Name Type(s) Description
true bool if the player is dead (set by the death effects function)
🔗 pseudogame.game.player.radius
Name Type(s) Description
the number player's radius
🔗 pseudogame.game.player.polygon
Name Type(s) Description
polygon Polygon the player triangle (use this for drawing)
generated by LDoc 1.5.0