Constructor
new module:common/game-map/GameMap()
Constructor is private.
See GameMap.parse or GameMap.generate for instances of GameMap
Properties:
Name | Type | Description |
---|---|---|
id |
string | Unique id for this map |
theme |
string | The theme for this map |
rooms |
Array.<Room> | The rooms in the map |
items |
Array.<Item> | The items in this map |
players |
Array.<Player> | The players in this map |
Methods
(static) generate(map, params) → {GameMap}
Geneate a game map
Parameters:
Name | Type | Description |
---|---|---|
map |
GameMap | The game map to store everything in |
params |
object | The game map generation parameters for the game map |
Returns:
- Type
- GameMap
(static) parse(json, map) → {GameMap}
Parse a previously serialized map
Parameters:
Name | Type | Description |
---|---|---|
json |
string | object | The serialized map |
map |
GameMap | The game map to use |
Returns:
- Type
- GameMap
(static) register(renderer)
Regester a renderer for rooms and corridors
Parameters:
Name | Type | Description |
---|---|---|
renderer |
Renderer | The renderer to use |
getRect(x, y) → {Room|Corridor}
Get the room of corridor that contains the x, y corrdinate otherwise return undefined
Parameters:
Name | Type | Description |
---|---|---|
x |
number | |
y |
number |
Returns:
- Type
- Room | Corridor
getSpawnPoint() → {object}
Get the spawn point for a player
Returns:
{x,y}
- Type
- object
isOnMap(x, y, isMonster) → {boolean}
Check if a point is on the map/floor
Parameters:
Name | Type | Description |
---|---|---|
x |
number | |
y |
number | |
isMonster |
boolean |
Returns:
- Type
- boolean
serialize() → {string}
Serialize the game map
Returns:
The serialized map
- Type
- string
Type Definitions
Renderer
A room and corridor renderer
Properties:
Name | Type | Description |
---|---|---|
name |
string | The name of the renderer |
canRender |
function | Can this render the room or corridor that is passed in |
render |
function | Render the actual room or corridor |