new World(widthopt, heightopt, dataopt, textureMapopt, skyBoxopt, typeTableopt, optionsopt)
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
width |
number |
<optional> |
24 | integer indicating the width of the world (number of block) | ||||||||||||||||||
height |
number |
<optional> |
24 | integer indicating the height of the world (number of block) | ||||||||||||||||||
data |
string |
<optional> |
null | block data for the world, e.g. "0,1,0,0,0,0,1,2,0,0,0,0...", can be an array of integer instead] | ||||||||||||||||||
textureMap |
Map |
<optional> |
null | [[0, texture], [1, texture], ...] | ||||||||||||||||||
skyBox |
object |
<optional> |
World.defaultSkyBox | sky box
Properties
|
||||||||||||||||||
typeTable |
object |
<optional> |
World.defaultTypeTable | block type table to interpret the data, default to the default table | ||||||||||||||||||
options |
object |
<optional> |
null |
Properties
|
Methods
addSprite(sprite)
add a sprite to the world
Parameters:
Name | Type | Description |
---|---|---|
sprite |
Sprite |
closeDoor(x, y)
Parameters:
Name | Type | Description |
---|---|---|
x |
number | x coordinate of the block |
y |
number | y coordinate of the block |
loadCeiling(ceilingMapData)
Parameters:
Name | Type | Description |
---|---|---|
ceilingMapData |
string | or a 1D/2D array, or a single number indicating the texture for all blocks |
loadFloor(floorMapData)
Parameters:
Name | Type | Description |
---|---|---|
floorMapData |
string | or a 1D/2D array, or a single number indicating the texture for all blocks |
loadMap(data, optionsopt)
Parameters:
Name | Type | Attributes | Default | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
string | block data for the world separated by comma, can be an array of integer instead | ||||||||||||||
options |
object |
<optional> |
null |
Properties
|
loadTextureMap(textureMap)
this function will not copy the Map
Parameters:
Name | Type | Description |
---|---|---|
textureMap |
Map |
moveDoor(x, y)
Parameters:
Name | Type | Description |
---|---|---|
x |
number | x coordinate of the block |
y |
number | y coordinate of the block |
openDoor(x, y)
Parameters:
Name | Type | Description |
---|---|---|
x |
number | x coordinate of the block |
y |
number | y coordinate of the block |
removeSprite(spriteIdx)
remove a sprite
Parameters:
Name | Type | Description |
---|---|---|
spriteIdx |
number | index of the sprite in the sprites array or the sprite itself |
update(frameRateopt)
update the state of the doors and push walls
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
frameRate |
number |
<optional> |
30 |