Exemplo n.º 1
0
Arquivo: Game.cs Projeto: Iseke/Mylabs
        public void Draw()
        {
            wall.Draw();
            food.Draw();
            while (true)
            {
                worm.Move();
                if (worm.body[0].Equals(food.body[0]))
                {
                    Voice();
                    worm.body.Add(new Point {
                        X = food.body[0].X, Y = food.body[0].Y
                    });

                    score++;
                    if (score % 5 == 0)
                    {
                        Console.Clear();
                        gameLevel++;
                        wall.LoadLevel(gameLevel);
                        Console.SetCursorPosition(0, 0);
                        wall.Draw();
                        worm.body.Clear();
                        worm.body.Add(new Point {
                            X = 13, Y = 13
                        });
                        worm.Draw();
                    }

                    food.GenerateRandom();

                    while (wall.IsBelongPoint(food.body[0]) || worm.IsBelongPoint(food.body[0]))
                    {
                        food.GenerateRandom();
                    }
                    food.Draw();

                    Console.SetCursorPosition(4, 22);


                    Console.Write("Your score : " + (score - 1));
                    Console.SetCursorPosition(4, 21);
                    Console.WriteLine("Stage - " + gameLevel);
                }
                else
                {
                    foreach (Point p in wall.body)
                    {
                        if (p.Equals(worm.body[0]))
                        {
                            VoiceGameOver();



                            Console.Clear();
                            Console.ForegroundColor = ConsoleColor.Red;
                            Console.WriteLine("Game Over!!!");
                            Console.WriteLine("Your score: " + (score - 1));
                            Console.WriteLine("Do want to save your result?");
                            WantsProcess(score - 1);
                            score1  = score;
                            score   = 1;
                            isalive = false;

                            Stop();
                        }
                    }
                }


                worm.Draw();

                Thread.Sleep(Game.speed);
            }
        }