Ejemplo n.º 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)
        {
            GraphicsDevice.Clear(Color.Black);

            spriteBatch.Begin();

            if (gameState == GameStates.TitleScreen)
            {
                spriteBatch.Draw(titleScreen,
                                 new Rectangle(0, 0, this.Window.ClientBounds.Width,
                                               this.Window.ClientBounds.Height), Color.White);
            }

            if ((gameState == GameStates.Playing) ||
                (gameState == GameStates.PlayerDead) ||
                (gameState == GameStates.GameOver))
            {
                space.Draw(spriteBatch);
                playerManager.Draw(spriteBatch);
                enemyManager.Draw(spriteBatch);
                explosionManager.Draw(spriteBatch);
                life.Draw(spriteBatch);

                spriteBatch.DrawString(
                    pericles14,
                    "Score : " + playerManager.PlayerScore.ToString(),
                    scoreLocation, Color.White);

                if (playerManager.Lives >= 0)
                {
                    spriteBatch.DrawString(pericles14,
                                           "Lives Remaining: " +
                                           playerManager.Lives.ToString(),
                                           livesLocation, Color.White);
                }
            }

            if ((gameState == GameStates.GameOver))
            {
                spriteBatch.DrawString(
                    pericles14, "G A M E  O V E R! ",
                    new Vector2(
                        this.Window.ClientBounds.Width / 2 -
                        pericles14.MeasureString
                            ("G A M E  O V E R! ").X / 2, 50),
                    Color.White);

                spriteBatch.DrawString(pericles14, makeHighScoreString(),
                                       new Vector2(320, 150), Color.Red);
                SaveHighScore();
            }

            spriteBatch.End();

            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }