/// <summary> /// Draws the game world in its current state. /// </summary> /// <param name="gameTime">An object that contains information about the game time that has passed.</param> /// <param name="spriteBatch">The sprite batch used for drawing sprites and text.</param> public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); // draw the background and score bar spriteBatch.Draw(background, Vector2.Zero, Color.White); spriteBatch.Draw(scoreBar, new Vector2(10, 10), Color.White); // draw all game objects ball.Draw(gameTime, spriteBatch); cannon.Draw(gameTime, spriteBatch); can1.Draw(gameTime, spriteBatch); can2.Draw(gameTime, spriteBatch); can3.Draw(gameTime, spriteBatch); // draw the score spriteBatch.DrawString(gameFont, "Score: " + Score, new Vector2(20, 18), Color.White); // draw the number of lives for (int i = 0; i < lives; i++) { spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 60), Color.White); } // if the game is over, draw the game-over sprite if (lives <= 0) { spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White); } spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); spriteBatch.Draw(background, Vector2.Zero, Color.White); ball.Draw(gameTime, spriteBatch); cannon.Draw(gameTime, spriteBatch); can1.Draw(gameTime, spriteBatch); can2.Draw(gameTime, spriteBatch); can3.Draw(gameTime, spriteBatch); spriteBatch.End(); }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.Begin(); spriteBatch.Draw(background, Vector2.Zero, Color.White); ball.Draw(gameTime, spriteBatch); cannon.Draw(gameTime, spriteBatch); can1.Draw(gameTime, spriteBatch); can2.Draw(gameTime, spriteBatch); can3.Draw(gameTime, spriteBatch); for (int i = 0; i < lives; i++) { spriteBatch.Draw(livesSprite, new Vector2(i * livesSprite.Width + 15, 20), Color.White); } if (IsGameOver) { spriteBatch.Draw(gameover, new Vector2(Painter.ScreenSize.X - gameover.Width, Painter.ScreenSize.Y - gameover.Height) / 2, Color.White); } spriteBatch.End(); }