-
Notifications
You must be signed in to change notification settings - Fork 1
Map Object
mapObject.js
Map(numRows, numCols, canvas, snakeBox)
Creates a new Map object.
numRows
Integer is the expected input value.
The intended number of rows for the game board.
numCols
Integer is the expected input value.
The intended number of columns for the game board.
canvas
A <canvas> element is the expected input value
Reference to the canvas element which the game will be rendered on.
snakeBox
A <div> element is the expected input value.
Reference to the parent div element of the canvas.
Map.width
The value is set to width of the parent <div> element of the canvas.
Map.height
The value is set to height of the parent <div> element of the canvas.
Map.numRows
The value is set to Map.height divided by the input parameter numRows.
Map.numCols
The value is set to Map.width divided by the input parameter numCols.
Map.backgroundColor
The value is set to a hexadecimal value as a string. For the color of the game board (#838383).
Map.canvas
The value is set by the input parameter canvas.
Map.ctx
The value is set to a 2D context of the Map.canvas property.
GetBlockSize()
Description:
Function to calculate each block's size. Takes the map height and divides it by the map width.
Parameters:
- N/A
What the function returns:
Each block's size.