API Docs for:
Show:

Player Class

Uses
Defined in: src/player.js:4

Represents the player. Very similar to Entity Handles functionality triggered by keyboard and mouse Input

Constructor

Player

(
  • game
)

Defined in src/player.js:4

Parameters:

  • game Game
    • game instance this obj is attached to

Methods

canMoveTo

(
  • x
  • y
)
Bool

Defined in src/player.js:153

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:

Bool:

getTileDrawData

() TileDrawData

Inherited from TileDraw: src/mixins.js:22

Returns as tileDataobject used by Renderer objects to draw tiles.

Returns:

init

(
  • game
)

Defined in src/player.js:58

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
)
Bool

Defined in src/player.js:198

Move action.

Parameters:

  • x Number
    • Map tile cood to move to.
  • y Number
    • Map tile cood to move to.

Returns:

Bool:

true if action was taken.

moveTo

(
  • x
  • y
)

Defined in src/player.js:164

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
)
Bool

Defined in src/player.js:175

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:

Bool:

true if action was taken.

updateFov

()

Defined in src/player.js:140

Updates this.fov

wait

()

Defined in src/player.js:225

Wait action.

Properties

bgColor

String | Bool

Defined in src/player.js:93

The background color the character displayed when rendering this player.

char

String

Defined in src/player.js:79

The character displayed when rendering this player.

color

String | Bool

Defined in src/player.js:86

The color of the character displayed when rendering this player.

dead

Bool

Defined in src/player.js:121

Determines if the player has been killed.

fov

FovROT

Defined in src/player.js:43

FovRot instance representing this entity's vision.

fovDirection

String

Defined in src/player.js:107

Direction of fov (not used for fieldRange 360) valid directions: ['up', 'down', 'left', 'right', 'up_left', 'up_right', 'down_left', 'down_right'].

fovFieldRange

Number

Defined in src/player.js:100

Field Range of this.fov (90, 180, or 360)

fovMaxViewDistance

Number

Defined in src/player.js:114

Max visible distance in tiles

game

Game

Defined in src/player.js:36

Game instance this obj is attached to.

name

String

Defined in src/player.js:50

Name used when referencing describing this player. Used in console messages.

x

Number

Defined in src/player.js:65

The map tile coordinate position of the player on the x axis.

y

Number

Defined in src/player.js:72

The map tile coordinate position of the player on the y axis.