Class: World

World(widthopt, heightopt, dataopt, textureMapopt, skyBoxopt, typeTableopt, optionsopt)

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
Name Type Description
sky string a string notation of color or a p5.Image object
ground string a string notation of color or a p5.Image object
front p5.Image can be a p5.Graphics object
middle p5.Image can be a p5.Graphics object
back p5.Image can be a p5.Graphics object
typeTable object <optional>
World.defaultTypeTable block type table to interpret the data, default to the default table
options object <optional>
null
Properties
Name Type Description
doorSpeed number how fast the door open and close, default to 0.01;
doorAutoClose boolean will the door close by it self, default to false;
doorClosingTime number if doorAutoClose is true, define how long the door will be open
Source:

Methods

addSprite(sprite)

add a sprite to the world
Parameters:
Name Type Description
sprite Sprite
Source:

closeDoor(x, y)

Parameters:
Name Type Description
x number x coordinate of the block
y number y coordinate of the block
Source:

loadCeiling(ceilingMapData)

Parameters:
Name Type Description
ceilingMapData string or a 1D/2D array, or a single number indicating the texture for all blocks
Source:

loadFloor(floorMapData)

Parameters:
Name Type Description
floorMapData string or a 1D/2D array, or a single number indicating the texture for all blocks
Source:

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
Name Type Description
doorSpeed number how fast the door open and close, default to 0.1;
doorAutoClose boolean will the door close by it self, default to false;
doorClosingTime number if doorAutoClose is true, define how long the door will be open
Source:

loadTextureMap(textureMap)

this function will not copy the Map
Parameters:
Name Type Description
textureMap Map
Source:

moveDoor(x, y)

Parameters:
Name Type Description
x number x coordinate of the block
y number y coordinate of the block
Source:

openDoor(x, y)

Parameters:
Name Type Description
x number x coordinate of the block
y number y coordinate of the block
Source:

removeSprite(spriteIdx)

remove a sprite
Parameters:
Name Type Description
spriteIdx number index of the sprite in the sprites array or the sprite itself
Source:

update(frameRateopt)

update the state of the doors and push walls
Parameters:
Name Type Attributes Default Description
frameRate number <optional>
30
Source: