Ejemplo n.º 1
0
        static Thread _updateCopter; // declaring a variable for the update copter loop

        static void Main(string[] args)
        {
            Menu.Show(FileLog.GetList()); // this will show the menu and get the list from the file log object and pass it the list is retreives
            DrawObstacles(15);            // this calls the draw obstacles method
            Console.CursorVisible   = false;
            Console.ForegroundColor = ConsoleColor.Green;
            GameRunning             = true;                                                                 // sets the game running boolean to true
            _updateCopter           = new Thread(copter.Update);                                            //instanciates and calls update method on the copter
            _updateCopter.Start();                                                                          // starts the copter update loop

            if (copter.CheckCollison(_obstacles, copter))                                                   //if the copter check collision returns true then do in the block
            {
                GameRunning = false;                                                                        //this will set the game loop to false
                Console.Beep(1000, 1000);                                                                   //this will make the console beep for 1 second
                FileLog.Write(Name, GameScore);                                                             //this will tell the file log object to write the name and score to the file
                DialogResult result = MessageBox.Show("Play Again?", "GAME OVER", MessageBoxButtons.YesNo); //this will show a message box with a yes and no button and record the result in the dialog result object
                if (result == DialogResult.Yes)                                                             //this will check to see if they selected option is yes
                {
                    Application.Restart();                                                                  //this will restart the application
                }
                else if (result == DialogResult.No)                                                         //this will check to see if the option chose is no
                {
                    Environment.Exit(1);                                                                    //this will close the application
                }
            }
        }