Implementing the Finishing Touches

Currently, you don't do anything with these state variables. You should implement the game-over logic first. You will force the player to hit any key to start the game. After the game is over (you've crashed), there will be a slight pause (approximately one second), and then hitting any key will start the game once again. The first thing you'll need to make sure is that while the game is over, you don't update any other state. So the very first lines in OnFrameUpdate should be

// Nothing to update if the game is over
if ((isGameOver) || (!hasGameStarted))

Now you need to handle the keystrokes to restart the game. At the very end of your OnKeyDown override, you can add this logic:

 if (isGameOver) { ...

Get Managed DirectX® 9 Kick Start: Graphics and Game Programming now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.