/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); // draw game objects burger.Draw(spriteBatch); foreach (TeddyBear bear in bears) { bear.Draw(spriteBatch); } foreach (Projectile projectile in projectiles) { projectile.Draw(spriteBatch); } foreach (Explosion explosion in explosions) { explosion.Draw(spriteBatch); } // draw score and health spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); // draw game objects burger.Draw(spriteBatch); foreach (TeddyBear bear in bears) { bear.Draw(spriteBatch); } foreach (Projectile projectile in projectiles) { projectile.Draw(spriteBatch); } foreach (Explosion explosion in explosions) { explosion.Draw(spriteBatch); } // draw score and health spriteBatch.DrawString(font, healthString, GameConstants.HEALTH_LOCATION, Color.White); spriteBatch.DrawString(font, scoreString, GameConstants.SCORE_LOCATION, Color.White); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); // draw game objects burger.Draw(spriteBatch); //spriteBatch.DrawLine(new Vector2(0, GameConstants.WindowHeight / 2), new Vector2(GameConstants.WindowWidth, GameConstants.WindowHeight / 2), Color.Red,1f); //spriteBatch.DrawLine(new Vector2(GameConstants.WindowWidth / 2, GameConstants.WindowHeight), new Vector2(GameConstants.WindowWidth / 2, 0), Color.Black, 1f); //spriteBatch.DrawLine(new Vector2(GameConstants.WindowWidth / 2, GameConstants.WindowHeight), new Vector2(GameConstants.WindowWidth / 2, 0), Color.Red); //spriteBatch.DrawLine(new Vector2(0, GameConstants.WindowHeight / 2),new Vector2(GameConstants.WindowWidth,GameConstants.WindowHeight/2), Color.Red); foreach (TeddyBear bear in bears) { bear.Draw(spriteBatch); } foreach (Projectile projectile in projectiles) { projectile.Draw(spriteBatch); } foreach (Explosion explosion in explosions) { explosion.Draw(spriteBatch); } // draw score and health spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.LightSlateGray); spriteBatch.Begin(); // draw game objects if (burger != null) { burger.Draw(spriteBatch); } if (bears.Any()) { foreach (TeddyBear bear in bears) { bear.Draw(spriteBatch); } } foreach (Projectile projectile in projectiles) { projectile.Draw(spriteBatch); } foreach (Explosion explosion in explosions) { explosion.Draw(spriteBatch); } // draw score, health, g/o foreach (Message message in messages) { if (!burgerDead) { message.Draw(spriteBatch, Color.Wheat); } } if (burgerDead) { eventMessage.Draw(spriteBatch, Color.Red); foreach (Message message in messages) { message.Draw(spriteBatch, Color.Beige); } } //alt way //spriteBatch.DrawString(font,scoreString, GameConstants.ScoreLocation, Color.Wheat); spriteBatch.End(); base.Draw(gameTime); }
/// <summary> /// This is called when the game should draw itself. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.CornflowerBlue); spriteBatch.Begin(); if (gameState == GameState.PLAY) { // draw game objects burger.Draw(spriteBatch); foreach (TeddyBear bear in bears) { bear.Draw(spriteBatch); } foreach (Projectile projectile in projectiles) { projectile.Draw(spriteBatch); } foreach (Explosion explosion in explosions) { explosion.Draw(spriteBatch); } // draw score and health spriteBatch.DrawString(font, healthString, GameConstants.HealthLocation, Color.White); spriteBatch.DrawString(font, scoreString, GameConstants.ScoreLocation, Color.White); spriteBatch.End(); } else if (gameState == GameState.PAUSED) { string pauseMessage = "P to Unpause!"; spriteBatch.DrawString(font, pauseMessage, new Vector2(GameConstants.WindowWidth / 2, GameConstants.WindowHeight / 2), Color.White); spriteBatch.End(); } else { string loseMessage = "You Lost! Final Score: " + score; spriteBatch.DrawString(font, loseMessage, new Vector2(GameConstants.WindowWidth / 2, GameConstants.WindowHeight / 2), Color.White); spriteBatch.End(); } base.Draw(gameTime); }