Player Class
Represents the player. Very similar to Entity Handles functionality triggered by keyboard and mouse Input
Constructor
Item Index
Properties
Methods
canMoveTo
-
x
-
y
Checks if this entity can move to the specified map tile
Parameters:
-
x
Number- The tile map x coord to check if this entity can move to.
-
y
Number- The tile map y coord to check if this entity can move to.
Returns:
getTileDrawData
()
TileDrawData
Returns as tileData
object used by Renderer
objects to draw tiles.
Returns:
init
-
game
Optional Callback. Called when the entity is first created. Intended to be assigned by Entity.Types.
Parameters:
-
game
Game- Game instance this obj is attached to.
move
-
x
-
y
Move action.
Parameters:
-
x
Number- Map tile cood to move to.
-
y
Number- Map tile cood to move to.
Returns:
true if action was taken.
moveTo
-
x
-
y
Changes the position of this entity on the map. this.canMoveTo() should always be checked before calling this.moveTo
Parameters:
-
x
Number- The tile map x coord to move to.
-
y
Number- The tile map y coord to move to.
update
-
action
Called when user key is pressed with action of key pressed as an arg.
Parameters:
-
action
String- action bound to key pressed by user
Returns:
true if action was taken.
updateFov
()
Updates this.fov
wait
()
Wait action.
Properties
bgColor
String | Bool
The background color the character displayed when rendering this player.
char
String
The character displayed when rendering this player.
color
String | Bool
The color of the character displayed when rendering this player.
dead
Bool
Determines if the player has been killed.
fovDirection
String
Direction of fov (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'].
fovFieldRange
Number
Field Range of this.fov (90, 180, or 360)
fovMaxViewDistance
Number
Max visible distance in tiles
name
String
Name used when referencing describing this player. Used in console messages.
x
Number
The map tile coordinate position of the player on the x axis.
y
Number
The map tile coordinate position of the player on the y axis.