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)) return;
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 the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.