public void Draw(SpriteBatch spriteBatch) { // If player is alive, draw the bullets and the flying animation. if (alive) { foreach (Bullet fireball in fireballs) { fireball.Draw(spriteBatch); } flySprite.DrawFrame(spriteBatch, position); } // If player recently died make the sprite blink and draw fireballs. else if (respawning) { if (respawnCounter % 4 == 0 && respawnCounter >= respawnTime) { flySprite.DrawFrame(spriteBatch, position); } foreach (Bullet fireball in fireballs) { fireball.Draw(spriteBatch); } } // Otherwise player is dying, so we draw the death animation else { deathSprite.DrawFrame(spriteBatch, position); } // Draws the outline for the player's food gauge on the right. spriteBatch.Draw(foodGauge, new Vector2(700, 250), null, Color.White, 0.0f, Vector2.Zero, 1.0f, SpriteEffects.None, 0f); // Draws the actual food gauge. The geometry here is confusing. Because XNA likes things to go top down, // what happens here is that we're kind of moving the starting point for the bar up and simaultaneously making // the bar bigger to make it look like it's filling up. Rectangle foodRect = new Rectangle( 0, 0, (int)foodBar.Width, (int)(foodBar.Height * gaugeLevel)); spriteBatch.Draw(foodBar, new Vector2(745, 315 + 256), foodRect, Color.White, 0.0f, new Vector2(0, foodBar.Height * gaugeLevel), 1.0f, SpriteEffects.None, 0.05f); }
public override void Draw(SpriteBatch spriteBatch, Vector2 screenPos, float scale) { // We want things drawn at the center of their position, not the top left AnimTexture.Rotation = Rotation; AnimTexture.DrawFrame(spriteBatch, screenPos, timeAlive, scale); }
public void Draw(SpriteBatch spriteBatch) // Draws a food object if it's in play. { if (inPlay) { foodImage.DrawFrame(spriteBatch, position); } }
public virtual void Draw(SpriteBatch spriteBatch) { // Basic Drawing functions. Depending on the animation, some subclasses will have to override this. foreach (Bullet bullet in bullets) { bullet.Draw(spriteBatch); } if (alive) { spriteAlive.DrawFrame(spriteBatch, position); // spriteBatch.Draw(sprite, position, Color.White); } if (!alive && spriteDead.Frame < spriteDead.framecount) { spriteDead.DrawFrame(spriteBatch, position); } }
/// <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) { graphics.GraphicsDevice.Clear(Color.CornflowerBlue); // Draw the sprite. spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend); //spriteBatch1.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend); spriteBatch.Draw(background, mainframe, Color.White); for (int i = 0; i < 32; i++) { switch (game.squares[i].squareType) { case CheckerType.redChecker: if (game.squares[i].highlighted) { spriteBatch.Draw(rCheck_H, game.squares[i].location, Color.White); } else { redCheckAnimated.DrawFrame(spriteBatch, game.squares[i].location); } //spriteBatch.Draw(rCheck, game.squares[i].location, Color.White); break; case CheckerType.whiteChecker: if (game.squares[i].highlighted) { spriteBatch.Draw(wCheck_H, game.squares[i].location, Color.White); } else { spriteBatch.Draw(wCheck, game.squares[i].location, Color.White); } break; case CheckerType.redKing: if (game.squares[i].highlighted) { spriteBatch.Draw(rKing_H, game.squares[i].location, Color.White); } else { spriteBatch.Draw(rKing, game.squares[i].location, Color.White); } break; case CheckerType.whiteKing: if (game.squares[i].highlighted) { spriteBatch.Draw(wKing_H, game.squares[i].location, Color.White); } else { spriteBatch.Draw(wKing, game.squares[i].location, Color.White); } break; } } spriteBatch.End(); //spriteBatch1.End(); base.Draw(gameTime); }