/// <summary> /// Draws the game world /// </summary> /// <param name="gameTime">The game time</param> protected override void Draw(GameTime gameTime) { #region Rendering while player lives if (destructionRendered == false) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(); foreach (var asteroid in asteroids) { asteroid.Draw(gameTime, spriteBatch); } ship.Draw(gameTime, spriteBatch); spriteBatch.DrawString(spriteFont, $"Lives left: {livesLeft}", new Vector2(2, 2), Color.Teal); spriteBatch.DrawString(spriteFont, $"Time Survived: {gameTime.TotalGameTime.TotalSeconds.ToString("0s")}", new Vector2(500, 2), Color.Teal); spriteBatch.End(); base.Draw(gameTime); } #endregion //Stops rendering on player death animation if (ship.Destroyed == true) { destructionRendered = true; } }
/// <summary> /// Draws the game /// </summary> /// <param name="gameTime">An object representing time in the game</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); // TODO: Add your drawing code here spriteBatch.Begin(); ship.Draw(gameTime, spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public void Draw(RenderTarget target, RenderStates states) { S.Draw(target, states); ShipSprite.Draw(target, states); bullets.Draw(target, states); //Lifebar zeichnen hud.Draw(target, states); if (explosions != null) { foreach (Explosion exp in explosions) { exp.Draw(target, states); } } }
/// <summary> /// Called 60 frames/per second and Draw all the /// sprites and other drawable images here /// </summary> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.LawnGreen); spriteBatch.Begin(); spriteBatch.Draw(backgroundImage, Vector2.Zero, Color.White); if (gameState == GameStates.Running) { restartButton.Draw(spriteBatch); // Draw asteroids game shipSprite.Draw(spriteBatch); asteroidController.Draw(spriteBatch); // Draw Chase game DrawGameStatus(spriteBatch); DrawGameFooter(spriteBatch); } else { if (gameState == GameStates.Won) { spriteBatch.DrawString(arialFont, "You have Won!", new Vector2(200, 600), Color.White); } else if (gameState == GameStates.Lost) { spriteBatch.DrawString(arialFont, "You have Lost!", new Vector2(200, 600), Color.White); } } spriteBatch.End(); base.Draw(gameTime); }