protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); switch (gameState) { case GameState.TITLE_SCREEN: spriteBatch.Draw(titleBG, screenBounds, Color.White); titleBox.Draw(spriteBatch); titleMenu.Draw(spriteBatch); credits.Draw(spriteBatch); break; case GameState.PLAYING: spriteBatch.Draw(gameBG, screenBounds, Color.White); world.Draw(spriteBatch); break; case GameState.INFO_SCREEN: spriteBatch.Draw(titleBG, screenBounds, Color.White); infoBox.Draw(spriteBatch); infoMenu.Draw(spriteBatch); credits.Draw(spriteBatch); break; case GameState.VICTORY_SCREEN: spriteBatch.Draw(victoryBG, screenBounds, Color.White); victoryBox.Draw(spriteBatch); victoryMenu.Draw(spriteBatch); credits.Draw(spriteBatch); thankYou.Draw(spriteBatch); break; case GameState.GAMEOVER_SCREEN: spriteBatch.Draw(gameoverBG, screenBounds, Color.White); gameoverBox.Draw(spriteBatch); gameoverMenu.Draw(spriteBatch); credits.Draw(spriteBatch); thankYou.Draw(spriteBatch); break; } spriteBatch.End(); base.Draw(gameTime); }
public void Draw(SpriteBatch spriteBatch) { // draw background tiles for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { if (Tiles[x, y] != null && Tiles[x, y].Background) { Tiles[x, y].Draw(spriteBatch); } } } // draw player and other entities Player.Draw(spriteBatch); if (Boss != null) { Boss.Draw(spriteBatch); } // draw foreground tiles for (int x = 0; x < Width; ++x) { for (int y = 0; y < Height; ++y) { if (Tiles[x, y] != null && !Tiles[x, y].Background) { Tiles[x, y].Draw(spriteBatch); } } } if (!IsPlayerDead) { spriteBatch.Draw(HealthBack, new Rectangle(0, 0, HealthBack.Width, HealthBack.Height), Color.White); spriteBatch.Draw(HealthFront, new Rectangle(0, 0, Player.Health * 2, HealthFront.Height), new Rectangle(0, 0, Player.Health * 2, HealthFront.Height), Color.White); } if (Boss != null) { spriteBatch.Draw(HealthBack, new Rectangle(600, 0, HealthBack.Width, HealthBack.Height), Color.White); spriteBatch.Draw(HealthFront, new Rectangle(600, 0, Boss.Health * 2, HealthFront.Height), new Rectangle(0, 0, Boss.Health * 2, HealthFront.Height), Color.White); } spriteBatch.Draw(Game1.blackRect, Game1.screenBounds, Color.White * 0.5f); if (menu != null) { menu.Draw(spriteBatch); } if (continueMenu != null) { continueMenu.Draw(spriteBatch); } if (displayBox != null) { displayBox.Draw(spriteBatch); } }