|
@ -82,6 +82,14 @@ public class Snake { |
|
|
return bodySegments; |
|
|
return bodySegments; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setDirection(SnakeDirection direction) |
|
|
|
|
|
{ |
|
|
|
|
|
if((this.direction == SnakeDirection.LEFT && direction != SnakeDirection.RIGHT) || |
|
|
|
|
|
(this.direction == SnakeDirection.RIGHT && direction != SnakeDirection.LEFT) || |
|
|
|
|
|
(this.direction == SnakeDirection.UP && direction != SnakeDirection.DOWN) || |
|
|
|
|
|
(this.direction == SnakeDirection.DOWN && direction != SnakeDirection.UP)) |
|
|
|
|
|
this.direction = direction; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|