0.4.0 • Published 5 years ago

dungeon-toolkit v0.4.0

Weekly downloads
-
License
MIT
Repository
-
Last release
5 years ago

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.

ParamTypeDescription
wNumberThe width of the map.
hNumberThe 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.

ParamTypeDescription
iNumberThe 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.

ParamTypeDescription
xNumberThe x coord.
yNumberThe y coord.

map.set(x, y, val)

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

Kind: instance method of Map

ParamTypeDescription
xNumberThe x coord of the tile to set.
yNumberThe y coord of the tile to set.
valNumberThe 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.

ParamTypeDescription
xNumberThe x coord.
yNumberThe 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.

ParamTypeDefaultDescription
xNumberThe x coord.
yNumberThe y coord.
distNumber1The distance to find neighbors within.
0.4.0

5 years ago

0.3.0

6 years ago

0.2.2

6 years ago

0.2.1

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago