private void DrawGameEntities(float elapsed) { foreach (var block in Blocks.Values) { block.UpdateColor(elapsed); } foreach (var block in scene.Map.Layer0) { skeletonBlock.Draw(spriteBatch, block); } foreach (var ball in scene.Balls) { BallUI.Draw(spriteBatch, ball); } foreach (var block in scene.Map.Layer1) { Blocks[block.Color].Draw(spriteBatch, block); } scene.Packages .Where(p => p.Type != PowerUpType.Nothing) .ToList() .ForEach(p => powerups[p.Type].Draw(spriteBatch, p)); }
public override void Draw(Graphics gfx) { foreach (GameObstacle obs in gameObstacles) { obs.Draw(gfx); } // Draw Player Sprite playerSprite.Draw(gfx); gameText.DrawText(gfx, score.ToString(), 32, Color.White, GameText.TextAlignment.TopCenter); }
public static void DrawInRect( SpriteBatch spriteBatch, GameSprite sprite, Rectangle bounds, HorizontalAlign alignHorizontal = HorizontalAlign.Center, VerticalAlign alignVertical = VerticalAlign.Middle ) { Vector2 location = Vector2.Zero; Vector2 origin = Vector2.Zero; switch (alignHorizontal) { case HorizontalAlign.Left: location.X = bounds.X; origin.X = 0; break; case HorizontalAlign.Center: location.X = bounds.X + bounds.Width / 2; origin.X = sprite.TextureRect.Width / 2; break; case HorizontalAlign.Right: location.X = bounds.X + bounds.Width; origin.X = sprite.TextureRect.Width; break; } switch (alignVertical) { case VerticalAlign.Top: location.Y = bounds.Y; origin.Y = 0; break; case VerticalAlign.Middle: location.Y = bounds.Y + bounds.Height / 2; origin.Y = sprite.TextureRect.Height / 2; break; case VerticalAlign.Bottom: location.Y = bounds.Y + bounds.Height; origin.Y = sprite.TextureRect.Height; break; } sprite.Draw(spriteBatch, location, sprite.Tint, sprite.Rotation, origin, sprite.Scale, sprite.SpriteEffects, sprite.Depth); }
public void Draw(SpriteBatch spriteBatch, Block model) { if (model.GetType() == typeof(FlashingBlock)) { flashingBlockUI.Draw(spriteBatch, model); } else if (model.GetType() == typeof(LightBlock)) { lightBlockUI.Draw(spriteBatch, model); } else { normalBlockUI.Draw(spriteBatch, model); } }
/// <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.Turquoise); spriteBatch.Begin(); bgSprite.Draw(spriteBatch); titleText2.Draw(spriteBatch); titleText1.Draw(spriteBatch); titleText3.Draw(spriteBatch); by.Draw(spriteBatch); coolPanel.Draw(spriteBatch); spriteBatch.DrawString(titleText1.Font, string.Format("X: {0} Y: {1}", currentMS.X, currentMS.Y), Vector2.Zero, Color.White); foreach (SlidingFont slidingFont in slidingText) { slidingFont.Draw(spriteBatch); } insertCoins.Draw(spriteBatch); insertFive.Draw(spriteBatch); donateHundred.Draw(spriteBatch); noCoinSpam.Draw(spriteBatch); colorfulTypingText.Draw(spriteBatch); regularTypingText.Draw(spriteBatch); allAchievementsDone.Draw(spriteBatch); spriteBatch.End(); base.Draw(gameTime); }
public static void FillRect( SpriteBatch spriteBatch, GameSprite sprite, Rectangle bounds, FillMode fillMode = FillMode.Scale, Vector2?scroll = null ) { var location = new Vector2(bounds.X, bounds.Y); var origin = Vector2.Zero; var rotation = 0.0f; var scale = Vector2.One; var depth = 0.0f; switch (fillMode) { case FillMode.Fill: scale.X = (float)bounds.Width / (float)sprite.TextureRect.Width; scale.Y = (float)bounds.Height / (float)sprite.TextureRect.Height; sprite.Draw(spriteBatch, location, sprite.Tint, rotation, origin, scale, SpriteEffects.None, depth); break; case FillMode.TileRandomFlipHorizontal: case FillMode.TileRandomFlipVertical: case FillMode.TileRandomFlipBoth: case FillMode.Tile: var rand = new Random(42); var doRand = scroll != Vector2.Zero; var startY = bounds.Y - (int)Math.Round(scroll.HasValue ? scroll.Value.Y : 0); var startX = bounds.X - (int)Math.Round(scroll.HasValue ? scroll.Value.X : 0); var rectHeight = sprite.TextureRect.Height; var rectWidth = sprite.TextureRect.Width; startY = startY % rectHeight; startX = startX % rectWidth; if (startY > 0) { startY -= rectHeight; } if (startX > 0) { startX -= rectWidth; } for (int y = startY; y < bounds.Y + bounds.Height; y += rectHeight) { location.Y = y; for (int x = startX; x < bounds.X + bounds.Width; x += rectWidth) { location.X = x; var spriteEffects = SpriteEffects.None; switch (fillMode) { case FillMode.TileRandomFlipHorizontal: if (doRand && rand.Next() % 2 == 1) { spriteEffects = SpriteEffects.FlipHorizontally; } break; case FillMode.TileRandomFlipVertical: if (doRand && rand.Next() % 2 == 1) { spriteEffects = SpriteEffects.FlipVertically; } break; case FillMode.TileRandomFlipBoth: if (doRand) { switch (rand.Next() % 4) { case 1: spriteEffects = SpriteEffects.FlipHorizontally; break; case 2: spriteEffects = SpriteEffects.FlipVertically; break; case 3: spriteEffects = SpriteEffects.FlipHorizontally | SpriteEffects.FlipVertically; break; } } break; } sprite.Draw(spriteBatch, location, sprite.Tint, rotation, origin, scale, spriteEffects, depth); } } break; case FillMode.Scale: default: var theScale = (float)bounds.Width / (float)sprite.TextureRect.Width; if (sprite.TextureRect.Height * theScale > bounds.Height) { theScale = (float)bounds.Height / (float)sprite.TextureRect.Height; location.Y = bounds.Height / 2 - (sprite.TextureRect.Height * theScale) / 2; } else { location.X = bounds.Width / 2 - (sprite.TextureRect.Width * theScale) / 2; } scale.X = scale.Y = theScale; sprite.Draw(spriteBatch, location, sprite.Tint, rotation, origin, scale, SpriteEffects.None, depth); break; } }
void DecoratorGame_CustomDrawing(GameTime gameTime) { character.Draw(gameTime, SpriteBatch); }
void FacadeGame_CustomDrawing(GameTime gameTime) { character.Draw(gameTime, SpriteBatch); }
void FlyweightGame_CustomDrawing(GameTime gameTime) { character.Draw(gameTime, SpriteBatch); }
void CommandGame_CustomDrawing(GameTime gameTime) { character.Draw(gameTime, SpriteBatch); }