public void Draw(GameTime gameTime, GraphicsDevice graphicsDevice, SpriteBatch spriteBatch) { switch (_currentMap) { case SimulationScreenMap.Urban: _playerGame.UrbanMap.Draw(gameTime); break; case SimulationScreenMap.Country: _playerGame.CountryMap.Draw(gameTime); break; case SimulationScreenMap.Ocean: _playerGame.OceanMap.Draw(gameTime); break; } spriteBatch.DrawLine(150, 0, 150, graphicsDevice.Viewport.Height, Color.White); spriteBatch.DrawLine(0, graphicsDevice.Viewport.Height - 100, graphicsDevice.Viewport.Width, graphicsDevice.Viewport.Height - 100, Color.White); /* Area selection */ Rectangle areaSelectionUrban = new Rectangle(5, graphicsDevice.Viewport.Height - 148, 43, 43); Rectangle areaSelectionCountry = new Rectangle(53, graphicsDevice.Viewport.Height - 148, 43, 43); Rectangle areaSelectionOcean = new Rectangle(101, graphicsDevice.Viewport.Height - 148, 43, 43); spriteBatch.DrawRectangle(0, graphicsDevice.Viewport.Height - 174, 150, 75, Color.White); spriteBatch.FillRectangle(areaSelectionUrban, (_currentMap == SimulationScreenMap.Urban ? Color.LightGray : Color.Gray)); spriteBatch.DrawRectangle(areaSelectionUrban, Color.White); spriteBatch.FillRectangle(areaSelectionCountry, (_currentMap == SimulationScreenMap.Country ? Color.LightGray : Color.Gray)); spriteBatch.DrawRectangle(areaSelectionCountry, Color.White); spriteBatch.FillRectangle(areaSelectionOcean, (_currentMap == SimulationScreenMap.Ocean ? Color.LightGray : Color.Gray)); spriteBatch.DrawRectangle(areaSelectionOcean, Color.White); }
public void DrawHealthBar(Vector2 position, SpriteBatch b) { if (Alive) { Rectangle barBG = new Rectangle((int)position.X, (int)position.Y, 100, 15); Rectangle bar = new Rectangle((int)position.X, (int)position.Y, (int)(100 * (Percent / 100f)), 15); b.FillRectangle(barBG, Color.White); b.FillRectangle(bar, Color.Red); } }
public void Draw(SpriteBatch spriteBatch) { spriteBatch.FillRectangle(Position, Size, BaseColor); spriteBatch.DrawRectangle(Position, Size, BorderColor); spriteBatch.DrawString(Font, Label + ": " + CurrentValue + " / " + MaxValue, new Vector2(Position.X + 1, Position.Y + Size.Y - Font.MeasureString(Label + ": " + CurrentValue + " / " + MaxValue).Y), TextColor); }
public void Draw(SpriteBatch b) { // Get starting position float startingPos = 1280 - ((25 + 5) * playerRef.Lives); for (int i = 0; i < playerRef.Lives; i++) { float position = startingPos + ((25 + 25) * i); b.Draw(livesTexture, new Vector2(position, 15), null, Color.White, 0f, Vector2.Zero, 0.75f, SpriteEffects.None, 0f); } b.Draw(coinTexture, new Vector2(1180, 90), null, Color.White, 0f, Vector2.Zero, 0.85f, SpriteEffects.None, 0f); b.DrawString(font, playerRef.CoinsCollected.ToString(), new Vector2(1240, 95), Color.Black); float mapProgression = (playerRef.Position.X / mapWidth); b.FillRectangle(new Vector2(540, 10), new Vector2(400, 20), Color.WhiteSmoke); b.FillRectangle(new Vector2(540 + (400 * mapProgression), 10), new Vector2(5, 20), Color.Black); }
public void DrawTooltip(SpriteBatch spriteBatch, GraphicsDevice graphicsDevice) { if (!hasTooltip) return; MouseState mouseState = Mouse.GetState(); int widthOfTooltip = graphicsDevice.Viewport.Width - mouseState.X - 18; // right padding, width of cursor bool tooltipToRightOfMouse = true; if (widthOfTooltip < 240) { tooltipToRightOfMouse = false; widthOfTooltip = mouseState.X - 5; // left padding } string[] tooltipLines = Skin.TooltipFont.WordWrap(Tooltip, widthOfTooltip); Vector2 tooltipSize = Skin.TooltipFont.MeasureStringMultiline(tooltipLines); tooltipSize.X += 2 * TooltipPadding; Vector2 tooltipLocation = new Vector2(mouseState.X + (tooltipToRightOfMouse ? 13 : 0), (mouseState.Y + tooltipSize.Y + 5 < graphicsDevice.Viewport.Height ? mouseState.Y : mouseState.Y - tooltipSize.Y)); spriteBatch.FillRectangle(tooltipLocation, tooltipSize, Color.Beige); spriteBatch.DrawRectangle(tooltipLocation, tooltipSize, Color.Black); spriteBatch.DrawStrings(Skin.TooltipFont, tooltipLines, tooltipLocation + new Vector2(TooltipPadding, 0), Color.Black); }
public override void DrawAt(GameTime gameTime, SpriteBatch spriteBatch, Vector2 pos, Vector2 size) { spriteBatch.FillRectangle(pos, size, ColorProperty); }
public virtual void Draw(SpriteBatch sb, GameTime gameTime) { sb.FillRectangle(size, color); }
public void DrawPhysicalContacts(SpriteBatch spriteBatch) { var numContacts = 0; var contact = World.GetContactList(); var drawingSize = new Vector2(4.0f, 4.0f); while (contact != null) { ++numContacts; Manifold manifold; contact.GetManifold(out manifold); WorldManifold worldManifold; contact.GetWorldManifold(out worldManifold); for (int i = 0; i < manifold._pointCount; i++) { var point = worldManifold._points[i]; spriteBatch.FillRectangle(point - drawingSize / 2, drawingSize, Microsoft.Xna.Framework.Color.Lime); } contact = contact.GetNext(); } if (game.drawDebugData.IsVerbose) { game.DrawOnScreen("Physical contacts: " + numContacts.ToString()); } }
public override void Draw(GameTime gameTime, SpriteBatch spriteBatch) { spriteBatch.FillRectangle(Position, Size, (Hovered ? Color.LightBlue : Color.Blue)); spriteBatch.DrawRectangle(Position, Size, Color.Black); }
public void Draw(SpriteBatch spriteBatch) { spriteBatch.FillRectangle(new Vector2(this.x, this.y), new Vector2(this.size*2, this.size), this.color); //spriteBatch.DrawString(); }
public void Draw(SpriteBatch spriteBatch) { if (world == null) { return; } foreach (var body in world.bodies) { var debugData = GetDebugDataForBody(body); foreach (var bodyPart in body.bodyParts) { DrawShape(debugData, spriteBatch, bodyPart.shape, body.transform); } } foreach (var body in world.bodies) { var debugData = GetDebugDataForBody(body); var boundingBox = body.calculateBoundingBox(); spriteBatch.DrawRectangle(scBoundingUtils.toXNARectangle(boundingBox), debugData.BodyBoundingBoxColor); // Draw rotation as a line. var rotated = new Vector2(debugData.BodyTransformRotationRadius, 0).Rotate(body.transform.rotation.radians); spriteBatch.DrawLine(body.transform.position, body.transform.position + rotated, debugData.BodyTransformRotationColor); // Draw position. var center = new Rectangle(); center.Width = debugData.BodyTransformPositionExtents; center.Height = debugData.BodyTransformPositionExtents; center.X = (int)(body.transform.position.X - center.Width / 2.0f); center.Y = (int)(body.transform.position.Y - center.Height / 2.0f); spriteBatch.FillRectangle(center, debugData.BodyTransformPositionColor); // Draw linear velocity spriteBatch.DrawLine(body.transform.position, body.transform.position + body.linearVelocity, debugData.BodyLinearVelocityColor); } // Draw view bounds spriteBatch.DrawRectangle(scBoundingUtils.toXNARectangle(world.viewBounds), ViewBoundsColor); bodyMap.Clear(); }