Reference Source Test
public class | source

PickCharacter

Used to load the character and items for the player

Constructor Summary

Public Constructor
public

constructor(game: Game)

Default constructor

Member Summary

Public Members
public
public

A reference to the entities in the game

public

Instance of the game

public

grids: [type]

Grids

public

Instance of the renderer

public

A reference to other game sprites in the game

Method Summary

Public Methods
public

addEntity(entity: Entity)

Adds an entity

public

clearPlayers(exception: Player)

Clears the other players from the grid to calculate pathing so they don't collide, then resets the players back into position

public

create()

Create the player in the game

public

exists(id: Number): *

Checks to see if an entity is there

public

forEachEntity(callback: Function)

Apply a callback function to every entity

public

forEachEntityAround(x: Number, y: Number, radius: Number, callback: Function)

Apply a callback function to entities within a position radius

public

get(id: Number): Entity

Return a specific entity by index

public

getAll(): Entity[]

Returns all available entities

public

Get a sprite by name

public

Load the character into the game

public

Register position with duality (two things in the same spot) so the entity is moved to a different spot

public

Register the position of an entity and add it to the player's grid

public

removeItem(item: Item)

Remove an item from the game

public

Remove an entity from a position on the grids

public

update()

Updating sprites in the game

Public Constructors

public constructor(game: Game) source

Default constructor

Params:

NameTypeAttributeDescription
game Game

Reference to the game class

Public Members

public decrepit: Object source

public entities: Array source

A reference to the entities in the game

public game: Game source

Instance of the game

public grids: [type] source

Grids

public renderer: Renderer source

Instance of the renderer

public sprites: Sprites source

A reference to other game sprites in the game

Public Methods

public addEntity(entity: Entity) source

Adds an entity

Params:

NameTypeAttributeDescription
entity Entity

instance of the entity to add

public clearPlayers(exception: Player) source

Clears the other players from the grid to calculate pathing so they don't collide, then resets the players back into position

Params:

NameTypeAttributeDescription
exception Player

Player to exlude when clearing

public create() source

Create the player in the game

public exists(id: Number): * source

Checks to see if an entity is there

Params:

NameTypeAttributeDescription
id Number

The ID of the entity

Return:

*

{Entity

public forEachEntity(callback: Function) source

Apply a callback function to every entity

Params:

NameTypeAttributeDescription
callback Function

the function to apply to every entity

public forEachEntityAround(x: Number, y: Number, radius: Number, callback: Function) source

Apply a callback function to entities within a position radius

Params:

NameTypeAttributeDescription
x Number

X coordinate in the grid

y Number

Y coordinate in the grids

radius Number

How many grid spaces in the circle radius

callback Function

The callback function to apply

public get(id: Number): Entity source

Return a specific entity by index

Params:

NameTypeAttributeDescription
id Number

returns an entity with that ID

Return:

Entity

public getAll(): Entity[] source

Returns all available entities

Return:

Entity[]

array of entities

public getSprite(name: String): Sprite source

Get a sprite by name

Params:

NameTypeAttributeDescription
name String

the name of the sprite

Return:

Sprite

returns the sprite if found

public loadCharacter() source

Load the character into the game

public registerDuality(entity: Entity) source

Register position with duality (two things in the same spot) so the entity is moved to a different spot

Params:

NameTypeAttributeDescription
entity Entity

An instance of an entity

public registerPosition(entity: Entity) source

Register the position of an entity and add it to the player's grid

Params:

NameTypeAttributeDescription
entity Entity

An instance of a player, mob, npc or chest

public removeItem(item: Item) source

Remove an item from the game

Params:

NameTypeAttributeDescription
item Item

An instance of an item

public unregisterPosition(entity: Entity) source

Remove an entity from a position on the grids

Params:

NameTypeAttributeDescription
entity Entity

remove the entity from the grid

public update() source

Updating sprites in the game