Tile
Simple module for creating Tiles with utility functions.
Example
var Tile = ; var person = name: 'eve' id : 'akjldh' items: ; var template = type: 'grass' style: 'grass_faded' visible: true blocking: false opacity: 001 impedance: 0 location: x: 2 y: 2;; var tile = template; tile;tile;
Methods
var Tile = ;
var tile = new Tile(opts)
Returns a new Tile
object.
opts
is an object to specify the tile's settings.
opts.location
required |object
withx
andy
coordinate values.opts.type
required |string
non-visual tileType (e.g'grass'
)opts.visible
optional |boolean
sets if the tile is visible.opts.style
required |string
used for choosing graphics (e.g'grass-top'
,'grass-faded'
)opts.blocking
optional |boolean
sets if the tile is passable or notopts.impedance
optional | (default: 0) |int (0 -> 1)
sets how much the tile affects travel through it.opts.opacity
optional | (default: 0 ) |opacity (0 -> 1)
sets how much the tile obscures vision.
tile.addUnit(unit)
Adds the unit.id
to it's unit
array.
tile.removeUnit(unit)
Removes the unit.id
to it's unit
array.
tile.copyWithUnits(visible)
visible
optional | boolean
(default: false)
Creates a copy of the Tile
with unit array, and sets it's visiblility to visible
argument.
tile.copyWithoutUnits()
visible
optional | boolean
(default: false)
Creates a copy of the Tile
without unit array, and sets it's visiblility to visible
argument.
tile.deepCopy()
Returns a complete deep copy of itself.
Installing
npm install habitants-tile
Test
npm test