Exemple #1
0
        public void Start()
        {
            isStarted = true;
            Position movement = new Position(0, 0);

            while (isStarted == true)
            {
                BoundariesChecker.CheckBoundaries(Snake.SnakeBody.Head.Value, movement);
                Snake.Move(movement);
                if (Snake.CheckSelfCanibalism())
                {
                    Console.Clear();
                    ConsoleHelper.Write(new Position(0, 0), "Game over! You ate yourself?????");
                    isStarted = false;
                    break;
                }

                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(false).Key;
                    movement = ReadUserInput.GetMovement(key, movement);
                }
                Thread.Sleep(40);
                gameItems.ForEach(i => i.Draw());
            }
        }
Exemple #2
0
        public void Start()
        {
            isStarted = true;
            Position movement = new Position(0, 0);

            while (isStarted == true)
            {
                Snake.Move(movement);

                if (Console.KeyAvailable)
                {
                    var key = Console.ReadKey(false).Key;
                    movement = ReadUserInput.GetMovement(key);
                }



                Thread.Sleep(50);
                Console.Clear();
                gameItems.ForEach(i => i.Draw());
            }
        }