Exemple #1
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            spriteBatch.Draw(mainBackground, rectBackground, Color.White);
            bgLayer1.Draw(spriteBatch);
            bgLayer2.Draw(spriteBatch);


            player.DrawBoundingBox(spriteBatch, GraphicsDevice);
            player.Draw(spriteBatch);
            lasers.Draw(spriteBatch);
            enemies.ForEach(enemy => enemy.Draw(spriteBatch));
            ExplosionAnimations.ForEach(explosion => explosion.Draw(spriteBatch));
            spriteBatch.DrawString(scoreFont, String.Format("Score {0:0}", score), new Vector2(5, 5), Color.Black);
            spriteBatch.DrawString(scoreFont, String.Format("Health {0:0}", player.Health), new Vector2(5, 20), Color.Black);

            if (state == GameState.PAUSED)
            {
                spriteBatch.DrawString(messageFont, "Game Paused, press <enter> to continue", new Vector2(5, (GraphicsDevice.Viewport.Height / 2) - 32), Color.Black);
            }
            if (state == GameState.GAME_OVER)
            {
                spriteBatch.DrawString(messageFont, String.Format("Game Over, Score {0:0} press <enter> to restart", score), new Vector2(5, (GraphicsDevice.Viewport.Height / 2) - 32), Color.Black);
            }
            spriteBatch.End();
            base.Draw(gameTime);
        }