API Docs for:
Show:

Entity Class

Uses
Defined in: src/entity.js:6

Represents an entity in the game. Usually a character or enemy. Manages state (position, health, stats, etc) Occupies a single game map tile.

Constructor

Entity

(
  • game
  • type
)

Defined in src/entity.js:6

Parameters:

  • game Game
    • Game instance this obj is attached to.
  • type String
    • Type of entity. When created this object is merged with the value of Entity.Types[type].

Methods

bump

(
  • entity
)
Bool

Defined in src/entity.js:179

Handles the behavior of a player or other entity attempting to move into the tile coord this entity is currently occupying.

Parameters:

  • entity Player | Entity
    • The player or entity attempting to move into this entity's tile.

Returns:

Bool:

true if bumping this entity completes the action of the bumping entity.

canMoveThrough

(
  • x
  • y
)
Bool

Defined in src/entity.js:131

Checks if an entity can move through a map tile. Convenience method for this.game.canMoveThrough()

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:

canMoveTo

(
  • x
  • y
)
Bool

Defined in src/entity.js:143

Checks if an entity can move through and into a map tile and that tile is un-occupied. Convenience method for this.game.entityCanMoveTo()

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:

canSeeThrough

(
  • x
  • y
)
Bool

Defined in src/entity.js:167

Checks if a map tile can be seen through. Convenience method for this.game.entityCanSeeThrough()

Parameters:

  • x Number
    • The x map tile coord to check.
  • y Number
    • The y map tile coord to check.

Returns:

Bool:

getTileDrawData

() TileDrawData

Inherited from TileDraw: src/mixins.js:22

Returns as tileDataobject used by Renderer objects to draw tiles.

Returns:

init

(
  • game
  • type
)

Defined in src/entity.js:53

Called when the entity is first created. Intended to be assigned by Entity.Types.

Parameters:

  • game Game
    • Game instance this obj is attached to.
  • type String
    • Type of entity. When created this object is merged with the value of Entity.Types[type].

moveTo

(
  • x
  • y
)

Defined in src/entity.js:155

Changes the position of this entity on the map. Convenience method for this.game.entityMoveTo() this.canMoveTo() and/or this.canMoveThrough() 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

()

Defined in src/entity.js:123

Called after a player action has been resolved. Resolves this entities turn.

Properties

bgColor

String | Bool

Defined in src/entity.js:97

The background color the character displayed when rendering this entity. Not rendered if false.

char

String

Defined in src/entity.js:83

The character displayed when rendering this entity.

color

String | Bool

Defined in src/entity.js:90

The color of the character displayed when rendering this entity. Not rendered if false.

dead

Bool

Defined in src/entity.js:104

Determines if this entity has been killed and needs to be removed.

game

Game

Defined in src/entity.js:32

Game instance this object is attached to.

name

String

Defined in src/entity.js:61

Name used when referencing or describing this entity. Used in console messages.

type

String

Defined in src/entity.js:45

The type of entity this is. When created this object is merged with the value of Entity.Types[type].

x

Number

Defined in src/entity.js:69

The x map tile coord of this entity.

y

Number

Defined in src/entity.js:76

The y map tile coord of this entity.