public void Move() { ConsoleWrapper.ConsoleWriteCharXY(BODY_CHAR, headX, headY); bodyCoords.Add(new Tuple <int, int>(headX, headY)); moveSnake(); checkWallCollision(headX, headY); checkSelfCollision(headX, headY); isMooving = false; }
public void spawnFood() { Random random = new Random(); var foodX = random.Next(1, Console.WindowWidth - 1); var foodY = random.Next(1, Console.WindowHeight - 2); foodList.Add(new Tuple <int, int>(foodX, foodY)); ConsoleWrapper.ConsoleWriteCharXY(FOOD_CHARACTER, foodX, foodY); }
public void InitialDrawSnakeHorizontal() { var currentX = headX; var currentY = headY; ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, headX, headY); for (int i = 0; i < this.Length; i++) { ConsoleWrapper.ConsoleWriteCharXY(BODY_CHAR, --currentX, currentY); bodyCoords.Add(new Tuple <int, int>(currentX, currentY)); } tailX = currentX; tailY = currentY; Console.SetCursorPosition(0, Console.WindowHeight - 1); }
private void moveTail() { ConsoleWrapper.ConsoleWriteCharXY(' ', tailX, tailY); removeBodyCoords(tailX, tailY); switch (tailQueue.Dequeue()) { case RIGHT: tailX++; break; case LEFT: tailX--; break; case UP: tailY--; break; case DOWN: tailY++; break; } }
private void moveDown() { ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, headX, ++headY); tailQueue.Enqueue(DOWN); }
private void moveUp() { ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, headX, --headY); tailQueue.Enqueue(UP); }
private void moveLeft() { ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, --headX, headY); tailQueue.Enqueue(LEFT); }
private void moveRight() { ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, ++headX, headY); tailQueue.Enqueue(RIGHT); }