Exemple #1
0
        /*GameOver method - used to end the game because the player is dead, calculating the lives left, Reload the screen with the dead player, Display the status on the screen*/
        private void GameOver()
        {
            GameTimer.Enabled = false;                                                                      // Stops the game timer to update the raindrops Y (vertical) position since the player is dead
            LivesUsed++;                                                                                    // Increment the lives the player already used up
            int remainingLives = playerLives - LivesUsed;                                                   // Calculating the remaining lives through subtracting the lives used from the total player lives

            Graphics deadPlayer = this.CreateGraphics();

            deadPlayer.Clear(Color.White);                                                                  // Clearing the screen
            this.Show();

            PlayerBuilder playerBuilder = new PlayerBuilder();                                              // Creating a new object of the PlayerBuilder class

            playerBuilder.KillPlayer(deadPlayer, POSx, POSy);                                               // using the object created to call the KillPlayer method to load the dead player

            /*Displaying the game over screen - Heading and loading the buttons to start the game*/

            btnEndGame.Visible = true;
            btnRestart.Visible = true;
            lblLives.Visible   = true;
            btnRestart.Text    = "Retry";
            lblLives.Text      = String.Format("GAME OVER !!!! {0} / {1} lives remaining.", remainingLives.ToString(), playerLives.ToString());

            if (remainingLives == 0)                                                                        // Checking the condition if the player used up all the lives
            {
                btnRestart.Enabled = false;                                                                 // Disabling the Restart button so that the player can't restart the game after the lives are finished
            }
        }
Exemple #2
0
        /*PlayerManager method - Loading the player start position once, Load the player in the specified position*/
        private void PlayerManager()
        {
            if (runOncePlayer)                                                                              // Will calculate the players start position for the starting of the game only once
            {
                runOncePlayer = false;
                CalcPlayerStartPOS();                                                                       // Calling the CalcPlayerStartPOS to calculate the players starting position
            }

            Graphics      playerGraphics = this.CreateGraphics();
            PlayerBuilder playerBuilder  = new PlayerBuilder();                                             // Creating a new object of the PlayerBuilder class

            playerGraphics = playerBuilder.BuildPlayer(playerGraphics, POSx, POSy);                         // using the object created to call the BuildPlayer method to build and load the Player
        }
Exemple #3
0
        /*PlayerManager method - Loading the player start position once, Load the player in the specified position*/
        private void PlayerManager()
        {
            if (runOncePlayer)                                                                              // Will calculate the players start position for the starting of the game only once
            {
                runOncePlayer = false;
                CalcPlayerStartPOS();                                                                       // Calling the CalcPlayerStartPOS to calculate the players starting position
            }

            Graphics playerGraphics = this.CreateGraphics();
            PlayerBuilder playerBuilder = new PlayerBuilder();                                              // Creating a new object of the PlayerBuilder class
            playerGraphics = playerBuilder.BuildPlayer(playerGraphics, POSx, POSy);                         // using the object created to call the BuildPlayer method to build and load the Player
        }
Exemple #4
0
        /*GameOver method - used to end the game because the player is dead, calculating the lives left, Reload the screen with the dead player, Display the status on the screen*/
        private void GameOver()
        {
            GameTimer.Enabled = false;                                                                      // Stops the game timer to update the raindrops Y (vertical) position since the player is dead
            LivesUsed++;                                                                                    // Increment the lives the player already used up
            int remainingLives = playerLives - LivesUsed;                                                   // Calculating the remaining lives through subtracting the lives used from the total player lives

            Graphics deadPlayer = this.CreateGraphics();
            deadPlayer.Clear(Color.White);                                                                  // Clearing the screen
            this.Show();

            PlayerBuilder playerBuilder = new PlayerBuilder();                                              // Creating a new object of the PlayerBuilder class
            playerBuilder.KillPlayer(deadPlayer, POSx, POSy);                                               // using the object created to call the KillPlayer method to load the dead player

            /*Displaying the game over screen - Heading and loading the buttons to start the game*/

            btnEndGame.Visible = true;
            btnRestart.Visible = true;
            lblLives.Visible = true;
            btnRestart.Text = "Retry";
            lblLives.Text = String.Format("GAME OVER !!!! {0} / {1} lives remaining.", remainingLives.ToString(), playerLives.ToString());

            if (remainingLives == 0)                                                                        // Checking the condition if the player used up all the lives
                btnRestart.Enabled = false;                                                                 // Disabling the Restart button so that the player can't restart the game after the lives are finished
        }