In my pirate game, if there’s a game over or a win, I create a new instance of the game, but I have a quick question. I don’t think I’m doing it correctly, and I’ll post code if needed, but the question is this: If I create a whole new instance of the game, should static variables be reset? Because how I have it right now, they do not. Basically, my createNewGame method consists of disposing of everything, then re-instantiating the whole thing.
So basically, here’s my game loop:
private void gameLoop() {
inputHandler.handleInput(this);
audioHandler.handleAudio(this);
if (GamePlayHelper.gameOver) {
setUpNewGame();
}
}
The last thing that setUpNewGame() does is call the create() method. Is that supposed to reset all the static variables too? I feel like I have to be doing this incorrectly, unless I actually do have to reset every single static variable manually, which I don’t understand if I’m creating a whole new instance of the game.
Class variables are reset correctly, but MOST of those are set in the constructor, but not all of them.
The code for the whole “myGame” file (not too big) is here
The imageLoader is not disposed of because for some reason if I do, the ground tiles don’t render.