I am making a game using the Monogame engine and I just need help on one part of my code. Now, every time the character dies in the game, the code just ends. this is because of these lines of code.
else
{
System.Environment.Exit(0);
}
if(y < 0)
{
System.Environment.Exit(0);
}
Now I want the game to have a 'game over' screen every time a user collides with one of the obstacles and this screen will allow you to go to the menu and allow users to play again. the classes I have at the minute is the game1.cs class, the character class and the obstacle class. Thanks for all your help.
You're going to want to keep track of the game state. As an example -- you might only have two states "Playing" and "GameOver". Instead of exiting in your code snippets, set the game state from "Playing" to "GameOver".
Now in the Update call -- you'll want to check for user input during GameOver and allow them to exit the game completely or start a new game.
In the Draw call -- you'll want to check the game state to decide what to render to the screen.