/// <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); if (logic.isDead) { GraphicsDevice.Clear(Color.Red); } // TODO: Add your drawing code here base.Draw(gameTime); spriteBatch.Begin(); for (int x = 0; x < logic.all.Count; x++) { GameObject go = logic.all[x]; Rectangle rc = new Rectangle((int)go.x - 10, (int)go.y - 10, 20, 20); SpriteToDraw whichSprite = go.GetSprite(); switch (whichSprite) { case SpriteToDraw.CrapFace: spriteBatch.Draw(m_crapFace, rc, Color.White); break; case SpriteToDraw.Player: spriteBatch.Draw(player_face, rc, Color.White); break; case SpriteToDraw.Fireball: spriteBatch.Draw(fire_ball, rc, Color.White); break; } } spriteBatch.End(); }
public virtual void Render() { if (SpriteToDraw == null) { SpriteToDraw = GetSprite(pManager.CurrentBaseSpriteKey); SpriteToDraw = new Sprite(SpriteToDraw); } var bounds = SpriteToDraw.LocalBounds; SpriteToDraw.Color = pManager.ValidPosition ? ValidPlaceColor : InvalidPlaceColor; SpriteToDraw.Position = new Vector2(MouseScreen.X - (bounds.Width / 2f), MouseScreen.Y - (bounds.Height / 2f)); //Centering the sprite on the cursor. SpriteToDraw.Draw(); }