Ejemplo n.º 1
0
        static public void Update()
        {
            ConsoleKeyInfo key;

            key = new ConsoleKeyInfo();
            while (key.Key != ConsoleKey.Spacebar && !SnakePointsManager.OnCollisionWalls() & !SnakePointsManager.OnCollisionSelf())
            {
                if (Console.KeyAvailable)
                {
                    key = Console.ReadKey(true);
                    CheckKeyPressed(key);
                    if (!pause)
                    {
                        SnakePointsManager.MoveController(key);
                    }
                }
                if (!pause)
                {
                    Thread.Sleep(UpdateTime);
                    Console.ForegroundColor = ConsoleColor.Red;
                    SnakePointsManager.EatingFruit();
                    SnakePointsManager.MoveSnake();
                    Console.ForegroundColor = ConsoleColor.White;
                    SnakePointsManager.ShowSceneSnake();
                }
            }
        }
Ejemplo n.º 2
0
 public SnakePoint(int x, int y, bool isHead = false)
 {
     X           = x;
     Y           = y;
     this.isHead = isHead;
     prevPoint   = SnakePointsManager.EndElement(this);
     SnakePointsManager.AddInList(this);
 }
Ejemplo n.º 3
0
        public static void GeneratePoint()
        {
            int    x, y;
            Random random = new Random();

            x = random.Next(1, WallPointsManager.Width - 1);
            y = random.Next(1, WallPointsManager.Height - 1);
            if (!SnakePointsManager.CheckedList(x, y) && !WallPointsManager.CheckedList(x, y) && !CheckedList(x, y))
            {
                FruitPoint fruitPoint = new FruitPoint(x, y);
            }
            else
            {
                GeneratePoint();
            }
        }
Ejemplo n.º 4
0
 static public void StartGame()
 {
     WallPointsManager.BuildSceneWalls(0, 0, 79, 79);
     SnakePointsManager.StartGame(10, 40);
     WallPointsManager.ShowSceneWalls();
     Console.ForegroundColor = ConsoleColor.Red;
     ShowLabel("Нажмите \"Escape\" чтобы начать игру", 20, 20);
     ShowLabel("Чтобы поставить игру на паузу нажмите \"Escape\"", 20, 21);
     ShowLabel("Чтобы убрать паузу нажмите \"Escape\"", 20, 22);
     ShowLabel("Чтобы принудительно закончить игру нажмите \"Space\"", 20, 23);
     Console.SetWindowSize(79, 79);
     Console.SetWindowPosition(0, 0);
     Console.SetBufferSize(79, 79);
     while (Console.ReadKey(true).Key != ConsoleKey.Escape)
     {
     }
     pause = !pause;
     ShowLabel("                                                        ", 20, 20);
     ShowLabel("                                                        ", 20, 21);
     ShowLabel("                                                        ", 20, 22);
     ShowLabel("                                                        ", 20, 23);
     FruitPointManager.GenerateFruits();
     FruitPointManager.ShowSceneFruit();
 }