public static void UpArrow()
        {
            _firstBtn = ConsoleKey.D5;
            ConsoleKeyInfo CKI = new ConsoleKeyInfo();

            _y--;
            Console.SetCursorPosition(_x, _y);
            Console.Write(_snake);
            upY++;
            if (upY >= _snakeIndex)
            {
                Console.SetCursorPosition(_x, _y + (_snakeIndex + 1));
                Console.Write(_snakeSpace);
            }

            if (_FoodX == _x && _FoodY == _y)
            {
                _snakeIndex++;
                FoodGeneration.RandomFoodGeneration();
            }

            if (_privateVaribale == false)
            {
                _privateVaribale = true;
                _i = 0;
            }

            _i++;

            if (_i == _snakeIndex)
            {
                fullSnake = true;
            }

            Thread.Sleep(400);

            if (Console.KeyAvailable == true)
            {
                CKI = Console.ReadKey(true);

                if (CKI.Key == ConsoleKey.DownArrow ^ CKI.Key == ConsoleKey.LeftArrow ^ CKI.Key == ConsoleKey.RightArrow)
                {
                    _userBtnRight = CKI.Key;

                    CoordinateRecord.AllCoordintatesRecords(_x, _y, fullSnake, _i, 4, _snakeIndex);
                    _i        = 0;
                    fullSnake = false;
                    upY++;
                    if (zxc == false)
                    {
                        privateVariable = true;
                        zxc             = true;
                    }
                }
            }
            else
            {
                _userBtnRight = ConsoleKey.UpArrow;
            }
        }
Пример #2
0
        static void Main(string[] args)
        {
            Console.CursorVisible = false;

            //Generation gaming field
            FieldsGeneration.DrawingGamingField();

            //Random food generation
            FoodGeneration.RandomFoodGeneration();

            //Random snake generation
            SnakeGeneration.RandomSnakeGeneration();

            //Snake movements
            SnakeMovements.MovementsSnake();
        }