Пример #1
0
        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);
        }
Пример #2
0
        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;
            }
        }
Пример #3
0
 private void moveDown()
 {
     ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, headX, ++headY);
     tailQueue.Enqueue(DOWN);
 }
Пример #4
0
 private void moveUp()
 {
     ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, headX, --headY);
     tailQueue.Enqueue(UP);
 }
Пример #5
0
 private void moveLeft()
 {
     ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, --headX, headY);
     tailQueue.Enqueue(LEFT);
 }
Пример #6
0
 private void moveRight()
 {
     ConsoleWrapper.ConsoleWriteCharXY(HEAD_CHAR, ++headX, headY);
     tailQueue.Enqueue(RIGHT);
 }