/// <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(); spriteBatch.Draw(mainBackground, Vector2.Zero, Color.White); // Draw the moving background bgLayer1.Draw(spriteBatch); bgLayer2.Draw(spriteBatch); // Draw the explosions for (int i = 0; i < explosions.Count; i++) { explosions[i].Draw(spriteBatch); } // Draw the Enemies for (int i = 0; i < enemies.Count; i++) { enemies[i].Draw(spriteBatch); } // Draw the Projectiles for (int i = 0; i < projectiles.Count; i++) { projectiles[i].Draw(spriteBatch); } player.Draw(spriteBatch); // Draw the score spriteBatch.DrawString(font, "score: " + score, new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y), Color.White); // Draw the player health spriteBatch.DrawString(font, "health: " + player.Health, new Vector2(GraphicsDevice.Viewport.TitleSafeArea.X, GraphicsDevice.Viewport.TitleSafeArea.Y + 30), 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); //Start Drawing spriteBatch.Begin(); //Draw background spriteBatch.Draw(mainBackground, Vector2.Zero, Color.Azure); bgLayer1.Draw(spriteBatch, Color.Azure); bgLayer2.Draw(spriteBatch, Color.Azure); //Draw Enemies foreach (Enemy enemy in enemies) { enemy.Draw(spriteBatch); } //Draw projectiles foreach (Projectile proj in projectiles) { proj.Draw(spriteBatch); } //Draw Player player.Draw(spriteBatch); //Draw Explosions foreach (Animation explo in explosions) { explo.Draw(spriteBatch); } //Draw UI ui.Draw(spriteBatch, GraphicsDevice.Viewport); //Stop drawing spriteBatch.End(); // TODO: Add your drawing code here 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(); spriteBatch.Draw(mainBackground, Vector2.Zero, Color.White); //Draw the moving background bgLayer1.Draw(spriteBatch); bgLayer2.Draw(spriteBatch); //Draw Player player.Draw(spriteBatch); //Draw Enemies for (int i = 0; i < enemies.Count; i++) { enemies[i].Draw(spriteBatch); } 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(); //Drawing code here background.Draw(spriteBatch); foreach (Enemy e in enemies) { e.Draw(spriteBatch); } foreach (Projectile p in projectiles) { p.Draw(spriteBatch); } player.Draw(spriteBatch); foreach (Animation e in explosions) { e.Draw(spriteBatch); } DrawText(spriteBatch, "Score: " + score, new Vector2(0, 0), Color.White); DrawText(spriteBatch, "Health: " + player.health, new Vector2(0, 30), Color.White); Vector2 leftThumbStick = GamePad.GetState(PlayerIndex.One).ThumbSticks.Left; DrawText(spriteBatch, "ThumbStickLeft: (" + leftThumbStick.X + "," + leftThumbStick.Y + ")", new Vector2(0, 60), Color.White); //End Drawing code spriteBatch.End(); base.Draw(gameTime); }
protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.Black); spriteBatch.Begin(); //Draw the Main Background Texture spriteBatch.Draw(mainBackground, rectBackground, Color.White); // Draw the moving background bgLayer1.Draw(spriteBatch); bgLayer2.Draw(spriteBatch); foreach (var a in asteroids) { if (a.Active) { a.Draw(spriteBatch); } } // Draw the Enemies foreach (var e in enemies) { e.Draw(spriteBatch); } foreach (var i in enemyLaserBeams) { i.Draw(spriteBatch); } if (shootingEnemy.Active) { shootingEnemy.Draw(spriteBatch); } if (healer.Active) { healer.Draw(spriteBatch); } if (bomb.Active) { bomb.Draw(spriteBatch); } foreach (var l in laserBeams) { l.Draw(spriteBatch); } if (player.Active) { player.Draw(spriteBatch); } foreach (var e in explosions) { e.Draw(spriteBatch); } healthBar.Draw(spriteBatch); if (gameState != GameState.Playing) { playButton.Draw(spriteBatch); exitButton.Draw(spriteBatch); } spriteBatch.DrawString(font, "SCORE:", new Vector2(5, 8), new Color(66, 171, 223) * 0.9f); spriteBatch.DrawString(font, player.Score.ToString(), new Vector2(110, 8), new Color(197, 198, 200) * 0.85f); spriteBatch.End(); base.Draw(gameTime); }