README
A toolkit of level generation and analysis utilities.
Map
A class representing a grid map.
Kind: global class
- Map
- new Map(w, h)
- .copy() ⇒
Map
- .indexToXY(i) ⇒
Object
- .xyToIndex(x, y) ⇒
Number
- .set(x, y, val)
- .get(x, y) ⇒
Number
- .getNeighbors(x, y, [dist]) ⇒
Array
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
map.copy() ⇒ Make a copy of this map.
Kind: instance method of Map
Returns: Map
- The copy of this map.
Object
map.indexToXY(i) ⇒ 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. |
Number
map.xyToIndex(x, y) ⇒ 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. |
Number
map.get(x, y) ⇒ 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. |
Array
map.getNeighbors(x, y, [dist]) ⇒ 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. |