Exemple #1
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            _scaler.SetRenderTarget();
            _spriteBatch.Begin();

            _spriteBatch.Draw(_bgScreen, Vector2.Zero, Color.White);

            // draw the enemy board
            _enemyGroup.Draw(gameTime, _spriteBatch);

            // draw the player shots
            foreach (PlayerShot playerShot in _playerShots)
            {
                playerShot.Draw(gameTime, _spriteBatch);
            }

            // draw the player
            if (_player != null)
            {
                _player.Draw(gameTime, _spriteBatch);
            }

            // draw the player explosion
            if (_playerExplosion != null)
            {
                _playerExplosion.Draw(gameTime, _spriteBatch);
            }

            Vector2 scoreSize = _font.MeasureString("Score: " + _score);

            _spriteBatch.DrawString(_font, "Score: " + _score, ScorePosition - scoreSize / 2.0f, Color.Aqua);

            _spriteBatch.End();
            _scaler.Draw();
        }
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            _scaler.SetRenderTarget();
            _spriteBatch.Begin();

            _spriteBatch.Draw(_bgScreen, Vector2.Zero, Color.White);

            // draw the enemy board
            _enemyGroup.Draw(gameTime, _spriteBatch);

            // draw the player shots
            foreach (PlayerShot playerShot in _playerShots)
            {
                playerShot.Draw(gameTime, _spriteBatch);
            }

            // draw the player
            if (_player != null)
            {
                _player.Draw(gameTime, _spriteBatch);
            }

            // draw the player explosion
            if (_playerExplosion != null)
            {
                _playerExplosion.Draw(gameTime, _spriteBatch);
            }

            //
            // TODO: Draw score
            //

            _spriteBatch.End();
            _scaler.Draw();
        }
Exemple #3
0
        public override void Draw(GameTime gameTime)
        {
            _spriteBatch.Begin();

            _spriteBatch.Draw(_bgScreen, Vector2.Zero, Color.White);

            // draw the enemy board
            _enemyGroup.Draw(gameTime, _spriteBatch);

            // draw the player shots
            foreach (PlayerShot playerShot in _playerShots)
            {
                playerShot.Draw(gameTime, _spriteBatch);
            }

            // draw the player
            if (_player != null)
            {
                _player.Draw(gameTime, _spriteBatch);
            }

            // draw the explosion
            if (_playerExplosion != null)
            {
                _playerExplosion.Draw(gameTime, _spriteBatch);
            }

            // draw the score
            Vector2 scoreSize = _font.MeasureString("Score: " + _score);

            _spriteBatch.DrawString(_font, "Score: " + _score, new Vector2((AlienAttackGame.ScreenWidth - scoreSize.X) / 2, 25), Color.Aqua);

            // draw the lives icon
            _livesIcon.Draw(gameTime, _spriteBatch);
            _spriteBatch.DrawString(_font, "x" + _lives, new Vector2(_livesIcon.Position.X + (_livesIcon.Width * _livesIcon.Scale.X) + 8, _livesIcon.Position.Y), Color.White);

            // draw the proper text, if required
            if (_enemyGroup.AllDestroyed())
            {
                Vector2 size = _font.MeasureString("You win!");
                _spriteBatch.DrawString(_font, "You win!", new Vector2((AlienAttackGame.ScreenWidth - size.X) / 2, (AlienAttackGame.ScreenHeight - size.Y) / 2), Color.Green);
            }

            if (_loseGame)
            {
                Vector2 size = _font.MeasureString("Game Over");
                _spriteBatch.DrawString(_font, "Game Over", new Vector2((AlienAttackGame.ScreenWidth - size.X) / 2, (AlienAttackGame.ScreenHeight - size.Y) / 2), Color.Red);
            }

            _spriteBatch.End();
        }