vantreeseba / dungeon-toolkit

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

A toolkit of level generation and analysis utilities.

Map

A class representing a grid map.

Kind: global class

new Map(w, h)

Construct a map.

Param Type Description
w Number The width of the map.
h Number The height of the map.

map.copy() ⇒ Map

Make a copy of this map.

Kind: instance method of Map
Returns: Map - The copy of this map.

map.indexToXY(i) ⇒ Object

Returns an x,y coord for a index in the array representing the map.

Kind: instance method of Map
Returns: Object - x,y coord.

Param Type Description
i Number The index to turn into an x,y coord.

map.xyToIndex(x, y) ⇒ Number

Turns an x,y coord into an index into the values array.

Kind: instance method of Map
Returns: Number - The index.

Param Type Description
x Number The x coord.
y Number The y coord.

map.set(x, y, val)

Set a value in the values array by x,y.

Kind: instance method of Map

Param Type Description
x Number The x coord of the tile to set.
y Number The y coord of the tile to set.
val Number The value to set for the tile.

map.get(x, y) ⇒ Number

Get a tiles value from the map by x,y.

Kind: instance method of Map
Returns: Number - The tile value at x,y.

Param Type Description
x Number The x coord.
y Number The y coord.

map.getNeighbors(x, y, [dist]) ⇒ Array

Get all neighbors for the tile within dist.

Kind: instance method of Map
Returns: Array - An array of tile objects.

Param Type Default Description
x Number The x coord.
y Number The y coord.
[dist] Number 1 The distance to find neighbors within.

About


Languages

Language:JavaScript 100.0%