Time for action – updating the Game1 class
- Add the following declarations to the Game1 class:
enum GameStates {TitleScreen, Playing, WaveComplete, GameOver}; GameStates gameState = GameStates.TitleScreen; float gameOverTimer = 0.0f; float gameOverDelay = 6.0f; float waveCompleteTimer = 0.0f; float waveCompleteDelay = 6.0f;
- Remove the call to
GoalManager.GenerateComputers()
from theLoadContent()
method of the Game1 class. - Add the
checkPlayerDeath()
method to the Game1 class:private void checkPlayerDeath() { foreach (Enemy enemy in EnemyManager.Enemies) { if (enemy.EnemyBase.IsCircleColliding( Player.BaseSprite.WorldCenter, Player.BaseSprite.CollisionRadius)) { gameState = GameStates.GameOver; } } }
- Replace the existing
Update()
method of the Game1 ...
Get XNA 4.0 Game Development by Example Beginner's Guide 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.