/// <summary> /// Constructor. /// </summary> /// <param name="game"></param> public GameController(GameWindow window) { _window = window; GameState = new GameState(); GameState.CurrentState = State.Menu; _gameOverTimer = new System.Timers.Timer(1000); _gameOverTimer.Elapsed += new ElapsedEventHandler(_OnTimedEvent); }
/// <summary> /// /// </summary> /// <param name="elapsedTime"></param> public void Update(double elapsedTime, GameState gameState) { for (int i = 0; i < _enemies.Length; i++) _enemies[i].UpdateFrame(elapsedTime); if (gameState.CurrentLevel > 1) for (int i = 0; i < _meteors.Length; i++) _meteors[i].UpdateFrame(elapsedTime); for (int i = 0; i < _fastStars.Length; i++) _fastStars[i].UpdateFrame(elapsedTime); for (int i = 0; i < _stars.Length; i++) _stars[i].UpdateFrame(elapsedTime); foreach (var rocket in _rockets) rocket.UpdateFrame(elapsedTime); foreach (var rocket in _enemyRockets) rocket.UpdateFrame(elapsedTime); _spaceShip.UpdateFrame(elapsedTime); _bonusLive.UpdateFrame(elapsedTime); }
/// <summary> /// /// </summary> /// <param name="spriteBatch"></param> public void Draw(SpriteBatch spriteBatch, GameState gameState) { _background.DrawSprite(spriteBatch); // Draw all the sprites. for (int i = 0; i < _stars.Length; i++) _stars[i].DrawSprite(spriteBatch); for (int i = 0; i < _fastStars.Length; i++) _fastStars[i].DrawSprite(spriteBatch); if (gameState.CurrentLevel > 1) for (int i = 0; i < _meteors.Length; i++) _meteors[i].DrawSprite(spriteBatch); for (int i = 0; i < _enemies.Length; i++) _enemies[i].DrawSprite(spriteBatch); foreach (var rocket in _rockets) rocket.DrawSprite(spriteBatch); foreach (var rocket in _enemyRockets) rocket.DrawSprite(spriteBatch); _spaceShip.DrawSprite(spriteBatch); _progress.DrawSprite(spriteBatch); _bonusLive.DrawSprite(spriteBatch); }