Our player can fire projectiles and destroy enemies. He can run into enemies and take damage. But right now the player does not get destroyed.
In this part of the tutorial, we will move to a Game Over state whenever the player gets destroyed. This will cover some of the basics of FantomEngine’s layers and scenes.
Game Over State
Right now, we only have the default layer and scene which we are playing our game in.
In order to be able to move to a Game Over state, we need to create a new scene that the game can transition too.
Now we have a play scene that we will run the game in, and a game over scene that we will show when the player gets destroyed.
Right now the game over scene doesn’t have anything in it. In the game’s OnCreate method, we will build our game over scene by adding some text that says “GAME OVER”.
It is important to remember with FantomEngine that whatever layer is the current default layer will be the one that things get added to. This is why we need to change the default layer to the game over layer when adding the Text object and switch back when we are done.
NOTE: The font system is not particularly well documented for FantomEngine. It supports FontMachine and EZGui style fonts. You will need a PNG file and a TXT file describing the layout in your project_name.data folder for it to work. I was able to use a tool called Hiero to convert Google font VT323 to this format. There will be an appendix section covering this. There is a sample font in the examples that come with FantomEngine which you can use in the meantime. I will also try to make the converted font I did available.
Our final step will be to add a check to the OnUpdate method to switch the scenes if the player is destroyed.
And now we have a playable and basic version of our game where the player can move, shoot enemies, and be destroyed which ends the game.