If you’ve made it this far through the RockBlaster tutorials, congratulations! We’ve covered a lot of topics in Glue and FlatRedBall. This last tutorial will clean up the game. All games require some polish and clean up before being finished. Normally this phase of game development takes a lot longer and covers far more than this tutorial, but we’ll keep it short to focus on Glue and FlatRedBall features.
Making Circles invisible
All entities with collision currently draw their circles. This is useful for understanding how large the collision area is and to identify bugs, but we need to turn off the shapes before marking the game as finished. To do this:
- In Glue, expand the Bullet Entity
- Expand the Objects item under Bullet
- Select the “CircleInstance” object.
- Change the “Visible” property to False
Repeat this process for:
- CircleInstance in MainShip
- CircleInstance in Rock
Now our game looks much better without the white circles:
Creating the End Game UI
If the user dies currently the game simply sits there and doesn’t let the player know what’s going on. We will use the EndGameUI Entity to inform the player that the game has ended. First, we’ll fill in the EndGameUI Entity. To do this:
- Expand the EndGameUi Entity in Glue
- Right-click on Objects
- Select “Add Object”
- Select “FlatRedBall or Custom Type”
- Select “Text” in the list box
- Enter the name “MessageObject” and click OK
- Scroll to the top of MessageObject’s properties and change DisplayText to “Game Over”
We don’t want the EndGameUi to show until the user loses, so we will want to allow it to be made visible and invisible:
- Select the EndGameUi Entity in Glue
- Set the ImplementsIVisible property to True
- Right-click on the Variables item under EndGameUi
- Select “Add Variable”
- Keep “Expose an existing variable” selected.
- Select “Visible” under “Select an existing variable:” and click OK
Adding EndGameUi to GameScreen
If you added the EndGameUi when we built the skeleton, then it should already show up in your game. If not, you will need to add it by dropping an instance into your GameScreen.
At this point the EndGameUi will show up in our game if we play it – but we don’t want it to show up until the game has ended. Therefore we want to initially make it invisible. To do this:
- Expand GameScren in Glue
- Expand the Objects in GameScreen
- Select EndGameUiInstance
- Change the “Visible” property to false in the EndGameUiInstance’s properties
Next we’ll want to detect if the game is over and show the hud if so. To do this:
- Open GameScreen.cs in Visual Studio
- Add the following to the CustomActivity in GameScreen.cs:
Next we’ll want to implement EndGameActivity. To do this:
- Add the following code to GameScreen.cs in the GameScreen class:
// If the list has 0 ships, then all have been killed
if (EndGameUiInstance.Visible == false && this.MainShipList.Count == 0)
EndGameUiInstance.Visible = true;
Now the GameOver will appear after all ships have died. If you have increased the ship’s health you will want to reduce it back to a reasonable number (like 6). This is important for the final state of the game as well as it will help you test the end game logic quicker.
Removing Debugger output
Not that we have the accumulation fixed we will need to remove the debugger code. To do this, open Game1.cs and locate the calls to the FlatRedBall.Debug.Debugger and remove those lines.
Way to go! You’ve just finished the RockBlaster tutorial series. We’ve covered a lot of features that are commonly used in FlatRedBall games. Of course there’s always more you can do to a game, and now that you’ve come this far we encourage you to experiment with the game. Here’s some things to try, some simple, and some more complex:
- Modifying the way the bullets fire. Possible ideas include
- A machine-gun that fires rapidly when holding the fire button down
- Spread fire
- Bullets which use different graphics and do area damage when exploding
- Make the rocks rotate randomly
- Add borders to the edge of the level so the player can’t leave the screen
- Stop rock spawning when the game has ended
- Add a background to the GameScreen
- Allow the user to restart the level by pushing a button when the game ends
- Implement the Explosion Entity. We created this but didn’t use it in the project. See if you can get it to show up when destroying Rocks.
There are endless possibilities. Good luck!