# Restarting a game be resetting an object [duplicate]

In a game I made, I want to restart the game when the players presses a button.

I have an instance of a Game class, which is where most of the game happens.

I though that I could simply initialize it again, and it will be reset.

Game game = new Game(); - When the program launches. game = new Game(); - When restarting the game.

But the game uses a lot of additional classes, such as Tank and Missile. Do I have to initialize all of them too, or is initializing the Game class, which will create new Tank objects and Missile objects (with the same reference names as the previous Game instance), enough?

In general, what would be the best way to reset a game or a level in a game?

Thanks

• How is this different than your last question? Note that there's no general best way to do anything in game development.
– House
Jan 25, 2014 at 21:12
– House
Jan 25, 2014 at 21:18

You already asked a very similar question to this, I have explained a simple ScreenManager's working process in this answer.

When you "unload" your screen, or Game class in your example, then you should remove every item, everything that is related to THAT game class. Storing the objects in Arrays, lists or vectors (depending on language) is (from my point of view) a good practice. It makes handling objects easier and more reachable.

Check my other answer (link above) to see how my simple ScreenManager is working.