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); }