|
|
@ -12,6 +12,22 @@ public class Snake { |
|
|
|
|
|
|
|
private SnakeDirection direction; |
|
|
|
|
|
|
|
|
|
|
|
private final int gridSize; |
|
|
|
|
|
|
|
public Snake(int gridSize) |
|
|
|
{ |
|
|
|
this.gridSize = gridSize; |
|
|
|
reset(); |
|
|
|
} |
|
|
|
|
|
|
|
public void reset() |
|
|
|
{ |
|
|
|
bodySegments.clear(); |
|
|
|
direction = SnakeDirection.UP; |
|
|
|
Point headLocation = new Point(gridSize/2, gridSize/2); |
|
|
|
bodySegments.add(headLocation); |
|
|
|
bodySegments.add(new Point(gridSize/2, gridSize/2 + 1)); |
|
|
|
bodySegments.add(new Point(gridSize/2, gridSize/2 + 2)); |
|
|
|
} |
|
|
|
|
|
|
|
} |