new Plane(p_init)
Parameters:
| Name | Type | Description |
|---|---|---|
p_init |
Object | Should contain the attributes
canvasID
(the id of the canvas tag),
colsNr
(the number of columns of the plane),
rowsNr
(the number of rows of the plane),
item
(the initialization object for the items
that are placed on the plane). |
Methods
-
addFood()
-
Places food on some empty place of the plane.
-
addItem(p_item)
-
Adds an item to the plane.
Parameters:
Name Type Description p_item$app$.game.snake.Item The item to be added. -
getItem(p_x, p_y) → {$app$.game.snake.Item}
-
Returns the item currently being placed on a specific field of the plane.
Parameters:
Name Type Description p_xint The x-position of the item to be fetched. p_yint The y-position of the item to be fetched. Returns:
The item at position (p_x,p_y) of the field. -
removeItem(p_item)
-
Removes an item from the plane.
Parameters:
Name Type Description p_item$app$.game.snake.Item The item to be removed. -
reset()
-
Resets the plane.