From b11bfe2e56257e86b75969c8d67f647d27bd96a4 Mon Sep 17 00:00:00 2001 From: Justin Senn Date: Mon, 6 Feb 2023 15:45:53 +0100 Subject: [PATCH] update --- src/main/java/Snake/Snake.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/main/java/Snake/Snake.java b/src/main/java/Snake/Snake.java index d13e1f9..8374677 100644 --- a/src/main/java/Snake/Snake.java +++ b/src/main/java/Snake/Snake.java @@ -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)); + } }