Ejemplo n.º 1
0
        public void MoveSnake()
        {
            while (anal)
            {
                worm.Clear();

                worm.Move();
                worm.Draw();
                ShowStatusBar(worm.body.Count.ToString());
                //worm.Draw();

                //CheckCollision();
                if (worm.IsIntersected(wall.body))
                {
                    Console.Clear();
                    Console.SetCursorPosition(15, 20);
                    Console.Write("Game over!");
                    anal = false;
                }
                if (worm.IsIntersected(food.body))
                {
                    anal = true;
                    worm.Eat(food.body);
                    food.GenerateLocation(worm.body, wall.body);
                    food.Draw();
                }
                else if (worm.snakegavno(worm.body))
                {
                    Console.Clear();
                    Console.SetCursorPosition(15, 20);
                    Console.Write("Game over!");
                    anal = false;
                }
                if ((Convert.ToInt32(worm.body.Count.ToString()) >= 1 && (Convert.ToInt32(worm.body.Count.ToString()) <= 3)))
                {
                    Thread.Sleep(150);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 4 && (Convert.ToInt32(worm.body.Count.ToString()) <= 7)))
                {
                    Thread.Sleep(100);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 8 && (Convert.ToInt32(worm.body.Count.ToString()) <= 10)))
                {
                    Thread.Sleep(50);
                }
                else if ((Convert.ToInt32(worm.body.Count.ToString()) >= 11))
                {
                    Thread.Sleep(10);
                }
            }
        }