The "game" object is a Game Object from the RouteEngineA1 javascript engine. See the RouteEngineA1 documentation for more details. RouteEngineA1 should be used for any UI elements, image loading, and sound loading.
Properties:
Name | Type | Description |
---|---|---|
drawGrid |
Boolean | If set to true, the game will render a black border round every block rendered. |
INTERVAL_TIME |
Integer | The number of milliseconds between each game tick interval. |
mouseX |
Number | The current x position of the user's cursor |
mouseY |
Number | The current y position of the user's cursor |
Members
(static) blockIdList
Holds a list of all block names and ids, indexed by names (blockIdList["dirt"] = 1)
(static) blockList
Holds a list of all Block objects, indexed by ids (blockList[0] = DirtBlockObject)
(static) cursor
Holds info about the current position of the user's cursor.
Properties:
Name | Type | Description |
---|---|---|
mScreenBlockX |
Integer | The x position of the block the cursor is over on the screen. Relative to the screen, not the map! |
mScreenBlockY |
Integer | The y position of the block the cursor is over on the screen. Relative to the screen, not the map! |
mapBlockPosition |
BlockPosition | The BlockPosition that the cursor is currently over. This is based on the SectoredBlockMap. |
(static) generation
Holds the global map generation settings for the game
Properties:
Name | Type | Description |
---|---|---|
GENERATE_WITH_PLAYER |
Boolean | If set to true, the map will generate a new sector whenever the player can see the edge of the map/an non generated sector. Default: true |
SECTOR_SIZE |
Integer | The height and width of one sector in blocks. This must be an ODD number! Default: 101 |
GENERATION_DISTANCE |
Integer | The number of sectors ahead that the WorldGenerator will generate around the player. Default: 1 |
(static) inputMatrix
Holds input about user interactions. Not necessarily key presses and mouse clicks, but those can be mapped to here too.
Properties:
Name | Type | Description |
---|---|---|
up |
Boolean | True if the user has triggered the "up" action. |
down |
Boolean | True if the user has triggered the "down" action. |
left |
Boolean | True if the user has triggered the "left" action. |
right |
Boolean | True if the user has triggered the "right" action. |
space |
Boolean | True if the user has triggered the "space" action. |
leftClick |
Boolean | True if the user has triggered the "left click" action. |
(static) view
Holds information about where the game's viewport/window is located. Basically, the set of coordinates that the user is will be looking at on their window.
Properties:
Name | Type | Description |
---|---|---|
focusSectorX |
Integer | The x index of the sector the game window is currently centered over |
focusSectorY |
Integer | The y index of the sector the game window is currently centered over |
focusLocalX |
Number | The x coordinate of the block in the focused sector that the game window is currently centered over. This can be a decimal! |
focusLocalY |
Number | The y coordinate of the block in the focused sector that the game window is currently centered over. This can be a decimal! |
Methods
(static) addBlock(src, solid, name) → {Integer}
This method is for registering normal sized blocks (square, taking up 1 tile) into the game. It enters the image to be loaded, assigns the image ID, and registers its name and ID into the blockList and blockIdList arrays.
Parameters:
Name | Type | Description |
---|---|---|
src |
String | The URI of the image for this block |
solid |
Boolean | If true, this block will be treated as a solid. If false, projectiles and entities will be able to pass through it. |
name |
String | The canonical name of this block ("dirt", "grass", "stone") |
Returns:
The Block ID of this block. This will represent the block in the BlockMap.
- Type
- Integer
(protected, static) calculateDimensions()
Called at the start of the game to calculate padding values and the amount of blocks that fit on the screen
Returns:
An object containing the values it calculated. You really don't need to know the specifics, this is a core function that should never be modified.
(static) drawArray(array)
Renders an array of blocks on the screen (does not adjust to padding or dimensions!)
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | An 2D array of blocks to be rendered. |
(static) drawCursor()
Renders the cursor on the game screen.
(static) drawEverything()
Draws EVERYTHING. Blocks, cursor, and player. Scrolling and padding is taken into account.
(static) generateMap()
Generates the map and initializes it
(static) loadAssets()
Loads all of the images, sounds, and other assets at the start of the game
(protected, static) locateCursor()
Updates game values to reflect the BlockPosition that the cursor is selecting
(static) onstart()
Initializes values, clears the screen, calls map generation, and calls for the game loop to start
(static) refocusView()
Realigns the global view settings to the position of the player
(static) startLoop()
Starts the main game loop
(static) stopLoop()
Stops the main game loop
(static) translateView()
Translates the game canvas according to scrolling and padding
(static) unTranslateView()
Un-translates the canvas after being translated by the game.translateView function.
Type Definitions
loop
The main loop for the game.