14. Cleaning Up

Introduction

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:

  1. In Glue, expand the Bullet Entity
  2. Expand the Objects item under Bullet
  3. Select the “CircleInstance” object.
  4. Change the “Visible” property to False

CollisionVisibleFalse.png

Repeat this process for:

  1. CircleInstance in MainShip
  2. CircleInstance in Rock

Now our game looks much better without the white circles:

WithoutCircles.png

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:

  1. Expand the EndGameUi Entity in Glue
  2. Right-click on Objects
  3. Select “Add Object”
  4. Select “FlatRedBall or Custom Type”
  5. Select “Text” in the list box
  6. Enter the name “MessageObject” and click OK
  7. 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:

  1. Select the EndGameUi Entity in Glue
  2. Set the ImplementsIVisible property to True
  3. Right-click on the Variables item under EndGameUi
  4. Select “Add Variable”
  5. Keep “Expose an existing variable” selected.
  6. 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:

  1. Expand GameScren in Glue
  2. Expand the Objects in GameScreen
  3. Select EndGameUiInstance
  4. Change the “Visible” property to false in the EndGameUiInstance’s properties

Detecting GameOver

Next we’ll want to detect if the game is over and show the hud if so. To do this:

  1. Open GameScreen.cs in Visual Studio
  2. Add the following to the CustomActivity in GameScreen.cs:

Next we’ll want to implement EndGameActivity. To do this:

  1. Add the following code to GameScreen.cs in the GameScreen class:

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.

GameOverDisplaying.png

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.

Conclusion

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!

<- 13. Destroying EntitiesBack to Tutorials ->