API Documentation:

Map:

Map(xDimensions, yDimensions, centerLocation,xCellSize, yCellSize, startTerrain)

Name

Type

Description

xDimensions

int

Width dimension of the map

yDimensions

int

Height dimension of the map

centerLocation

vec2

Center of the map

xCellSize

int

Width of each map block

yCellSize

int

Height of each map block

startTerrain

TerrainSet

Initial terrains for the map

Creates a new map with the height of the map being yDimensions * yCellSize and the width being xDimensions * xCellSize.

initMap()

Initializes a map at the start with default values

addUserUnit(newUnit)

Name

Type

Description

newUnit

transform

A user units transform

Adds a user units transform to keep track of

getWidth()

Returns the width of the map

getHeight()

Returns the height of the map

getCenterLocation()

Returns the center location of the map

toggleDelete()

Changes the delete mode to true/false

toggleTerrain()

Changes the terrain mode to true/false

toggleEdit()

Changes the edit mode to true/false

modifySpace()

Changes the map block at the position of the map selector depending on the current mode of it

selectObject()

Selects the source texture for new map objects

addMapObject(xPos, yPos)

Name

Type

Description

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

Adds new map object at position x, y to the map object set. Does not allow placing objects on untraversable terrain or in spaces already occupied by another object

removeMapObject(xPos,yPos)

Name

Type

Description

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

Removes a map object at position x, y from the map object set if there is an object present.

addObjectType(textPath, passability)

Name

Type

Description

textPath

string

The path of the object

passability

boolean

Whether or not the object can be passable

Adds MapObject behavior of a new Object to the map to define whether a MapObject is passable or not.

getTileMapObject(xPos, yPos)

Name

Type

Description

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

Returns the object at the given position. Returns null if no Object in that space

selectTerrain()

Sets the current terrain that will be placed on the map

placeTerrain(xPos, yPos)

Name

Type

Description

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

Changes the terrain object at position x, y. Does not allow placing untraversable terrain if an object is occupying the same space.

addTerrainType(textPath, traversability)

Name

Type

Description

textPath

string

The path of the object

traversability

boolean

Whether or not the object can be traversable

Adds Terrain behavior of a new Terrain to the map to define whether a terrain is traversable or not.

getTileTerrain(xPos,yPos)

Name

Type

Description

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

Returns the Terrain at the given position

clearMap()

Remove everything that has been placed

saveMap(mapName)

Name

Type

Description

mapName

string

Name of the map object to be saved

Saves the current map to the ResourceMap

loadMap(mapName)

Name

Type

Description

mapName

string

Name of the map object to be loaded

Loads a map from the ResourceMap

update()

Updates the position of the map selector or the position of the hero, if placed

draw(aCamera)

Draws all the terrain objects and then any map objects

MapObject:

MapObject(objText, xPos, yPos,xSize,ySize)

Name

Type

Description

objText

string

Path of the texture renderable for the map object

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

xSize

int

Width of the map object

ySize

int

Height of the map object

Creates a new map object at the position x, y

setDelete()

Sets delete to true

getDelete()

Returns the boolean value of delete

setPassability(pass)

Name

Type

Desctription

pass

boolean

Whether or not the object can be passable

Sets the passability of the map object

getPassability()

Returns the passability of the map object

draw(aCamera)

Draws the map object on the map

MapObjectSet:

MapObjectSet()

Creates an empty array to keep track of map objects

size()

Returns the size of the array

getObjectAt(index)

Name

Type

Description

index

int

Index of the map object in the array

Returns the map object at the index

addToSet(obj)

Name

Type

Description

obj

mapObject

The map object to be saved in the array

Adds the map object to the array

update()

Keeps the array of map objects updated

draw(aCamera)

Draws all the objects that are in the array

MapSelector:

MapSelector(map,xSize,ySize)

Name

Type

Description

map

Map

The map the selector is placed on

xSize

int

Width of the map selector

ySize

int

Height of the map selector

Creates a selector on the map

changeMode()

Changes the mode of the selector to create or delete

MoveLeft()

Moves the selector object left

MoveRight()

Moves the selector object right

MoveUp()

Moves the selector object up

MoveDown()

Moves the selector object down

leftBoundJudgement()

Returns a boolean value whether the selector is at the left boundary

rightBoundJudgement()

Returns a boolean value whether the selector is at the right boundary

topBoundJudgement()

Returns a boolean value whether the selector is at the top boundary

bottomBoundJudgement()

Returns a boolean value whether the selector is at the bottom boundary

update()

Updates the position and mode of the selector

draw(mCamera)

Draws the selector on the map

Terrain:

Terrain(terrainTexture,traversability, xPos, yPos, xSize,ySize)

Name

Type

Description

terrainTexture

string

Path of the texture renderable for the terrain

xPos

int

World coordinate unit on the x axis

yPos

int

World coordinate unit on the y axis

xSize

int

Width of the terrain

ySize

int

Height of the terrain

Creates a new terrain at the position x,y

setTraversability(trav)

Name

Type

Desctription

trav

boolean

Whether or not the object can be traversable

Sets the traversability of the terrain

getTraversability()

Gets the traversability of the terrain

draw(aCamera)

Draws all the terrain on the map

TerrainSet:

TerrainSet()

Creates an empty array to keep track of the terrains

size()

Returns the size of the array

getObjectAt(index)

Name

Type

Description

index

int

Index of the terrain in the array

Returns the terrain at index

addToSet(obj)

Name

Type

Description

obj

Terrain

The terrain to be saved in the array

Adds the terrain to the array

update()

Keeps the array of terrains updated

draw(aCamera)

Draws all the terrains that are in the array