new Snake(p_init, p_plane)
Parameters:
| Name | Type | Description |
|---|---|---|
p_init |
Object | Should contain three initialization objects to initialize the snake:
p_init.tail,
p_init.length, and
p_init.direction. |
p_plane |
$app$.game.snake.Plane | The plane where the snake is to be placed. |
Members
-
<static, constant> EAST :Object
-
Type:
- Object
-
<static, constant> LEFT :String
-
Type:
- String
-
<static, constant> NORTH :Object
-
Type:
- Object
-
<static, constant> RIGHT :String
-
Type:
- String
-
<static, constant> SOUTH :Object
-
Type:
- Object
-
<static, constant> WEST :Object
-
Type:
- Object
-
length :int
-
The current length of the snake.
Type:
- int
Methods
-
move() → {Boolean}
-
Moves the snake one field further. If it hits a food item, it grows. If it hits a wall or body item, it dies.
Returns:
true, if and only if the snake is dead.- Type
- Boolean
-
reset()
-
Resets the snake.
-
turnLeft(p_direction)
-
Turns the snake 90° to the left or to the right.
Parameters:
Name Type Description p_directionString Either Snake.LEFTorSnake.RIGHT.