Ejemplo n.º 1
0
        public void Draw()
        {
            food.Draw();
            Console.ForegroundColor = ConsoleColor.Blue;
            Console.SetCursorPosition(15, 24);

            Console.WriteLine("SCORE:{0}", score);
            wall.Draw();

            while (true)
            {
                worm.Move();
                Console.ForegroundColor = ConsoleColor.Blue;
                Console.SetCursorPosition(15, 24);
                Console.WriteLine("              ");
                Console.SetCursorPosition(15, 24);
                Console.WriteLine("SCORE:{0}", score);

                if (worm.body[0].Equals(food.body[0]))
                {
                    worm.body.Add(new Point {
                        X = food.body[0].X, Y = food.body[0].Y
                    });
                    food.body[0] = food.CreateFood(wall.body, worm.body);

                    score++;
                }
                else
                {
                    foreach (Point p in wall.body)
                    {
                        if (p.Equals(worm.body[0]))
                        {
                            Console.Clear();
                            Console.SetCursorPosition(10, Game.boardH / 2);
                            Console.WriteLine("GAME OVER!!!");
                            isAlive = false;
                            Console.ForegroundColor = ConsoleColor.Black;

                            Stop();
                        }
                    }
                }
                if (score == 3)
                {
                    wall.CleanBody();


                    interval  = 200;
                    gameLevel = GameLevel.Second;
                    wall.LoadLevel(GameLevel.Second);

                    Console.Clear();
                    wall.Draw();

                    food.body[0] = food.CreateFood(wall.body, worm.body);
                    worm.body.Clear();
                    worm.body.Add(new Point {
                        X = 24, Y = 16
                    });
                    score++;
                    continue;
                }
                worm.Draw();
                food.Draw();
                Thread.Sleep(Game.interval);
            }
        }