protected override void Draw(GameTime gameTime) { GraphicsDevice.Clear(Color.White); spriteBatch.Begin(); player.Draw(spriteBatch); map.Draw(spriteBatch); // Option One (if you have integer size and coordinates) //spriteBatch.Draw(rectangle, new Rectangle((int)pos.X, 20, 30, 30), Color.White); // Option Two (if you have floating-point coordinates) //spriteBatch.Draw(whiteRectangle, new Vector2(10f, 20f), null, // Color.Chocolate, 0f, Vector2.Zero, new Vector2(80f, 30f), // SpriteEffects.None, 0f); 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.White); // TODO: Add your drawing code here spriteBatch.Begin(); if (!_player.Active) { spriteBatch.DrawString(font, "You died!", new Vector2(200, 200), Color.Red); } else { _player.Draw(spriteBatch); foreach (var b in Bullets) { b.Draw(spriteBatch); } foreach (var e in enemies) { e.Draw(spriteBatch); } ; foreach (var b in EnemyBullets) { b.Draw(spriteBatch); } spriteBatch.DrawString(font, "Health: " + _player.Health.ToString(), new Vector2(20, 20), Color.Blue); } spriteBatch.DrawString(font, "Score: " + Score.ToString(), new Vector2(GraphicsDevice.Viewport.TitleSafeArea.Width - 100, 20), Color.Blue); spriteBatch.End(); base.Draw(gameTime); }