diff --git a/CCI_Java/CCI_Java/src/version3/SnakeGame.java b/CCI_Java/CCI_Java/src/version3/SnakeGame.java index 68091ff4bbb7a8f78beebd500c77325f3a5bfbf4..3c1dae6830b335f6aa39e0ef95bed22b32b71858 100644 --- a/CCI_Java/CCI_Java/src/version3/SnakeGame.java +++ b/CCI_Java/CCI_Java/src/version3/SnakeGame.java @@ -17,15 +17,15 @@ public class SnakeGame { } public void initialize() { - direction = Direction.NORTH; + direction = Direction.EAST; int startL = GRID_LINES / 2; int startC = GRID_COLUMNS / 2; gameOver = false; setApple(); segments = new ArrayList<Position>(); segments.add(new Position(startL, startC)); - segments.add(new Position(startL + 1, startC)); - segments.add(new Position(startL + 2, startC)); + segments.add(new Position(startL, startC - 1)); + segments.add(new Position(startL, startC - 2)); } @@ -51,18 +51,17 @@ public class SnakeGame { return false; } - public boolean isAppleAt(Position position) { return position.isSamePosition(apple); } - + public void print() { - for (int L =0; L < GRID_LINES; L++) { - for (int c =0; c<GRID_COLUMNS;c++) { + for (int L = 0; L < GRID_LINES; L++) { + for (int c = 0; c < GRID_COLUMNS; c++) { Position tmp = new Position(L, c); - if(isAppleAt(tmp)) + if (isAppleAt(tmp)) System.out.print(" A "); - else if(isSnakeAt(tmp)) + else if (isSnakeAt(tmp)) System.out.print(" S "); else System.out.print(" _ "); @@ -70,7 +69,7 @@ public class SnakeGame { System.out.println(); } } - + // public void printLine() { // String line = ""; // for (int c =0; c<GRID_COLUMNS;c++) {