# Game Over

## The screen itself

The image was created by prompting DALL.E-3 with ideas of a "game over screen featuring Mr. Peanut as a character."

### The trigger

The trigger to display the game over screen happens within FrmBattle.cs Form. The Form FrmGameOver is newly initialized and shown when the player's health is at or below zero.&#x20;

```clike
if (player.Health <= 0)
            {
                FrmGameOver frmGameOver = new FrmGameOver();
                frmGameOver.Show();

                instance = null;
                Close();
            }
```

## How it works

### Try Again and Quit Buttons

<figure><img src="https://1055530831-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTLAKl9MnL4UmPhZlb3vF%2Fuploads%2Fs17UdMf0CPG93eeVY5MT%2FUntitled.png?alt=media&#x26;token=853b8d41-1681-48b1-bb2f-ab2ee17f7138" alt=""><figcaption></figcaption></figure>

These buttons are presented to the player in a new window after their health depletes in battle. The functionality of the buttons are below.

```csharp
// quit button
private void button2_Click(object sender, EventArgs e) {
    Application.Exit();
}

// retry button
private void button1_Click(object sender, EventArgs e) {
    Application.Restart();
}
```

These buttons simply use a built-in class within the project that handles the properties and static methods of a Windows Forms application, such as starting and stopping an application, Windows message processing, and fetching application properties.

Application.Exit() informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.

Application.Restart() shuts down the application and starts a new instance immediately.
