Storing highscores in autoloads
Now that the player can fight back and survive, we might need to give the player a goal to attain – something that will make them play again and again. We could add a highscore – for example, the amount of time the player was able to survive. The player can then try to better their own time or compare times with their friends.
To achieve this, we will be using an autoload. This is a node that gets initialized at the start of the game and will exist throughout the complete execution of the game.
Using an autoload
The survival time should be stored somewhere so that it is easily accessible from anywhere within the game. This way, we can change it after the player dies but also display the score on the main menu, for example.
Normal nodes and scenes have to be managed by us, the programmer. But there is another kind of node that we could use: autoloads. An autoload is a scene or script that is always loaded. The Godot engine initiates...