protected override void Draw(GameTime gameTime) { _spriteBatch.Begin(); backgroundSprite.Draw(_spriteBatch); if (playerSprite.playerLives > 0) { playerSprite.Draw(_spriteBatch); } foreach (MissileSprite missile in missileList) { missile.Draw(_spriteBatch); } foreach (ParticleSprite particle in particleList) { particle.Draw(_spriteBatch); } _spriteBatch.DrawString(uiFont, "Lives: " + playerSprite.playerLives, new Vector2(12, 12), Color.Black); _spriteBatch.DrawString(uiFont, "Lives: " + playerSprite.playerLives, new Vector2(10, 10), Color.White); _spriteBatch.DrawString(uiFont, "Time:: " + Math.Round(playTime), new Vector2(16, 48), Color.Black); _spriteBatch.DrawString(uiFont, "Time: " + Math.Round(playTime), new Vector2(16, 46), Color.White); if (playerSprite.playerLives <= 0) { Vector2 textSize = bigFont.MeasureString("GAME OVER!"); _spriteBatch.DrawString(bigFont, "GAME OVER!", new Vector2((screenSize.X / 2) - (textSize.X / 2), (screenSize.Y / 2) - (textSize.Y / 2)), Color.White); _spriteBatch.DrawString(bigFont, "GAME OVER!", new Vector2((screenSize.X / 2 + 8) - (textSize.X / 2 + 8), (screenSize.Y / 2 + 8) - (textSize.Y / 2 + 8)), Color.Black); MediaPlayer.Stop(); } _spriteBatch.End(); // TODO: Add your drawing code here base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); _spriteBatch.Begin(); background.Draw(_spriteBatch); if (playerSprite.playerLives >= 0) { playerSprite.Draw(_spriteBatch); } foreach (MissileSprite missile in missiles) { missile.Draw(_spriteBatch); } foreach (ParticleSprite particle in particleList) { particle.Draw(_spriteBatch); } _spriteBatch.DrawString(uiFont, "Player lives: " + playerSprite.playerLives, new Vector2(6, 22), Color.White); _spriteBatch.DrawString(uiFont, "Time: " + Math.Round(playTime), new Vector2(6, 44), Color.White); if (playerSprite.playerLives <= 0) { Vector2 textSize = bigFont.MeasureString("GAME OVER"); _spriteBatch.DrawString( bigFont, "GAME OVER", new Vector2((screenSize.X / 2) - (textSize.X / 2) - 5, (screenSize.Y / 2) - (textSize.Y / 2) - 5), Color.Gray); _spriteBatch.DrawString( bigFont, "GAME OVER", new Vector2((screenSize.X / 2) - (textSize.X / 2), (screenSize.Y / 2) - (textSize.Y / 2)), Color.White); } _spriteBatch.End(); base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); _spriteBatch.Begin(); backgroundSprite.Draw(_spriteBatch); if (playerSprite.playerLives > 0) { playerSprite.Draw(_spriteBatch); } foreach (MissileSprite missile in missileList) { missile.Draw(_spriteBatch); } foreach (ParticleSprite particle in particleList) { particle.Draw(_spriteBatch); } _spriteBatch.DrawString( UiFont, "Lives: " + playerSprite.playerLives, new Vector2(14, 14), Color.Black ); _spriteBatch.DrawString( UiFont, "Lives: " + playerSprite.playerLives, new Vector2(10, 10), Color.White ); _spriteBatch.DrawString( UiFont, "Time: " + Math.Round(playTime), new Vector2(14, 44), Color.Black ); _spriteBatch.DrawString( UiFont, "Time: " + Math.Round(playTime), new Vector2(10, 40), Color.White ); if (playerSprite.playerLives <= 0) { Vector2 textSize = BigFont.MeasureString("GAME OVER"); _spriteBatch.DrawString( BigFont, "GAME OVER", new Vector2((screenSize.X / 2) - (textSize.X / 2) + 8, (screenSize.Y / 2) - (textSize.Y / 2) + 8), Color.Black ); _spriteBatch.DrawString( BigFont, "GAME OVER", new Vector2((screenSize.X / 2) - (textSize.X) / 2, (screenSize.Y / 2) - (textSize.Y / 2)), Color.White ); } _spriteBatch.End(); base.Draw(gameTime); }