void RenderMiniMap(IntRect size, List <GameObject> objects, Player player) { CircleShape circle = new CircleShape(); circle.Radius = 2.0f; circle.Origin = new Vector2f(circle.GetLocalBounds().Left + circle.GetLocalBounds().Width / 2, circle.GetLocalBounds().Top + circle.GetLocalBounds().Height / 2); circle.OutlineColor = new Color(0, 0, 0); circle.OutlineThickness = 1; RectangleShape rect = new RectangleShape(new Vector2f(size.Width + circle.Radius, size.Height + circle.Radius)); rect.Position = new Vector2f(size.Left - circle.Radius, size.Top); rect.FillColor = new Color(200, 200, 200, 230); rect.OutlineThickness = 1; rect.OutlineColor = new Color(0, 0, 0); rendertexture.Draw(rect); int MINIMAPRANGE = player.GetMiniMapRange(); for (int n = 0; n < objects.Count; n++) { if (Math.Abs(player.GetPosition().X - objects[n].GetPosition().X) < MINIMAPRANGE && Math.Abs(player.GetPosition().Y - objects[n].GetPosition().Y) < MINIMAPRANGE && objects[n].GetVisible()) { Color fillcol; if (objects[n].GetFixed()) { fillcol = new Color(0, 200, 0); } else { fillcol = new Color(0, 0, 200); } float objx = (objects[n].GetPosition().X - player.GetPosition().X) * size.Width / (MINIMAPRANGE * 2) + size.Width / 2 + size.Left; float objy = (objects[n].GetPosition().Y - player.GetPosition().Y) * size.Height / (MINIMAPRANGE * 2) + size.Height / 2 + size.Top; circle.FillColor = fillcol; circle.Position = new Vector2f(objx, objy); rendertexture.Draw(circle); } } /* * circle.Radius = 5.0f; * circle.Origin = new Vector2f(circle.GetLocalBounds().Left + circle.GetLocalBounds().Width/2, circle.GetLocalBounds().Top + circle.GetLocalBounds().Height/2); * circle.FillColor = new Color(200, 0, 0); * circle.Position = new Vector2f(size.Left + size.Width/2, size.Top + size.Height/2); * circle.SetPointCount(3); * circle.Rotation = (float)(player.GetAngle()*180.0/Math.PI) + 90; * rendertexture.Draw(circle);*/ ConvexShape playershape = new ConvexShape(3); playershape.SetPoint(0, new Vector2f((float)(6 * Math.Cos(player.GetAngle())), (float)(6 * Math.Sin(player.GetAngle())))); playershape.SetPoint(1, new Vector2f((float)(4 * Math.Cos(player.GetAngle() + Math.PI * 120 / 180)), (float)(4 * Math.Sin(player.GetAngle() + Math.PI * 120 / 180)))); playershape.SetPoint(2, new Vector2f((float)(4 * Math.Cos(player.GetAngle() + Math.PI * 240 / 180)), (float)(4 * Math.Sin(player.GetAngle() + Math.PI * 240 / 180)))); playershape.FillColor = new Color(200, 0, 0); playershape.Position = new Vector2f(size.Left + size.Width / 2, size.Top + size.Height / 2); rendertexture.Draw(playershape); }
public Vertex(char label, Vector2f pos) { this.label = label; previous = '0'; distance = uint.MaxValue; shape = new CircleShape(20); shape.FillColor = new Color(55, 200, 255); //invisible shape.OutlineThickness = 5; shape.OutlineColor = new Color(255, 255, 255); //white shape.Position = pos + new Vector2f(5, 5); //for outlinethickness shape.Origin = new Vector2f(shape.GetGlobalBounds().Width / 2, shape.GetGlobalBounds().Height / 2); center = new CircleShape(5); center.Origin = new Vector2f(center.GetGlobalBounds().Width / 2, center.GetGlobalBounds().Height / 2); center.FillColor = new Color(255, 0, 0); center.Position = pos; bounds = new RectangleShape(new Vector2f(shape.GetLocalBounds().Width, shape.GetLocalBounds().Height)); bounds.Origin = new Vector2f(bounds.GetLocalBounds().Width / 2, bounds.GetLocalBounds().Height / 2); bounds.FillColor = new Color(0, 0, 0, 0); bounds.OutlineThickness = 2; bounds.OutlineColor = new Color(0, 0, 0); //white bounds.Position = pos; Font font = new Font("resources/fonts/Font1.ttf"); if (font == null) { System.Console.WriteLine("No Such Font"); } labelchar = new Text(); labelchar.Font = font; labelchar.CharacterSize = 40; labelchar.Color = new Color(255, 255, 255); labelchar.DisplayedString = label + ""; labelchar.Position = pos + new Vector2f(-2, -12); //font offset labelchar.Origin = new Vector2f(labelchar.GetGlobalBounds().Width / 2, labelchar.GetGlobalBounds().Height / 2); }
private void Update(double delta) { _world.Step((float)delta); Vector2 circlePos = _circleBody.Position * MeterInPixels; float circleRot = _circleBody.Rotation; _circleSprite.Position = new Vector2f(circlePos.X - (_circleSprite.GetLocalBounds().Width / 2f), circlePos.Y - (_circleSprite.GetLocalBounds().Height / 2f)); _circleSprite.Rotation = circleRot; // Vector2 groundPos = _groundBody.Position*MeterInPixels; // _groundSprite.Position = new Vector2f( // groundPos.X - (_groundSprite.GetLocalBounds().Width/2f), // groundPos.Y ); }
public void Update(List <Particle> particles) { window.DispatchEvents(); window.Clear(); var circle = new CircleShape(3); foreach (var particle in particles) { if (isGravityConfig) { circle.Radius = particle.GetParticleData <GravityParticleData>()?.Radius ?? 3; } circle.Position = new Vector2f(particle.Position.X, particle.Position.Y); circle.FillColor = particle.ParticleData.Color; circle.Origin = new Vector2f(circle.GetLocalBounds().Width / 2f, circle.GetLocalBounds().Height / 2f); window.Draw(circle); } window.Display(); }
public RadioButton(Vector2f ButtonPosition, ButtonFunctions WhatToPaint) { CircleShape OuterCircle = new CircleShape(15f); OuterCircle.FillColor = OuterCircle_FillColor; OuterCircle.Origin = new Vector2f(OuterCircle.GetLocalBounds().Width / 2f, OuterCircle.GetLocalBounds().Height / 2f); OuterCircle.Position = ButtonPosition; ButtonShape_Outer = OuterCircle; ButtonShape_Inner = new CircleShape(ButtonShape_Outer.Radius * 0.50f); ButtonShape_Inner.FillColor = ButtonShape_Outer.FillColor; ButtonShape_Inner.Origin = new Vector2f(ButtonShape_Inner.GetLocalBounds().Width / 2f, ButtonShape_Inner.GetLocalBounds().Height / 2f); ButtonShape_Inner.Position = ButtonShape_Outer.Position; ButtonFunction = WhatToPaint; RadioButtonList.Add(this); }
protected override void UpdateDrawable() { base.UpdateDrawable(); if (isCircle) { var circle = new CircleShape(radius); circle.OutlineThickness = OutlineThickness; circle.OutlineColor = OutlineColor.SFMLColor; circle.FillColor = Color.SFMLColor; circle.SetPointCount((uint)CirclePointCount); SFMLDrawable = circle; Width = (int)circle.GetLocalBounds().Width; Height = (int)circle.GetLocalBounds().Height; } else { if (isShape) { var rect = new RectangleShape(new Vector2f(rectWidth, rectHeight)); rect.OutlineColor = OutlineColor.SFMLColor; rect.OutlineThickness = OutlineThickness; rect.FillColor = Color.SFMLColor; SFMLDrawable = rect; Width = (int)rect.GetLocalBounds().Width; Height = (int)rect.GetLocalBounds().Height; } else { SFMLVertices.Clear(); float x1, y1, x2, y2, u1, v1, u2, v2, cx1, cy1, cx2, cy2; cx1 = ClippingRegion.Left; cy1 = ClippingRegion.Top; cx2 = ClippingRegion.Right; cy2 = ClippingRegion.Bottom; x1 = Util.Max(0, cx1); u1 = TextureLeft + x1; if (FlippedX) { u1 = TextureRegion.Width - u1 + TextureLeft + TextureRegion.Left; } y1 = Util.Max(0, cy1); v1 = TextureTop + y1; if (FlippedY) { v1 = TextureRegion.Height - v1 + TextureTop + TextureRegion.Top; } x2 = Util.Min(TextureRegion.Right, cx2); u2 = TextureLeft + x2; if (FlippedX) { u2 = TextureRegion.Width - u2 + TextureLeft + TextureRegion.Left; } y2 = Util.Min(TextureRegion.Bottom, cy2); v2 = TextureTop + y2; if (FlippedY) { v2 = TextureRegion.Height - v2 + TextureTop + TextureRegion.Top; } SFMLVertices.Append(x1, y1, Color, u1, v1); SFMLVertices.Append(x1, y2, Color, u1, v2); SFMLVertices.Append(x2, y2, Color, u2, v2); SFMLVertices.Append(x2, y1, Color, u2, v1); Width = TextureRegion.Width; Height = TextureRegion.Height; } } }
public static List <Entity> CreateChooseFrame( int width, int height, int x, int y, int textX, int textY, string textString, int labelX, int labelY, string labelText, int leftX, int leftY, int rightX, int rightY, Name bgName = null, Name textName = null, Name leftName = null, Name rightName = null ) { var chooseFrame = new List <Entity>(); var textLabel = new Entity(Registrator.GenerateName(BaseNames.Text)); var tlDisplayComponent = new DisplayComponent(); var tlText = new Text(labelText, new Font(Assets.Font), (uint)Layout.FontSize); tlDisplayComponent.DisplayObject = tlText; var tlPositionComponent = new PositionComponent(); tlPositionComponent.X = labelX; tlPositionComponent.Y = labelY; textLabel.AddComponent(tlDisplayComponent); textLabel.AddComponent(tlPositionComponent); var textFrame = CreateTextFrame(width, height, x, y, textX, textY, textString, bgName, textName); var optionLeftButton = new Entity(leftName); var lDisplayComponent = new DisplayComponent(); var lShape = new CircleShape(Layout.OptionEntryButtonSize, 3); lShape.Origin = new SFML.System.Vector2f( lShape.GetLocalBounds().Width / 2, lShape.GetLocalBounds().Height / 2 ); lShape.FillColor = Color.Transparent; lShape.OutlineThickness = 3; lShape.OutlineColor = Color.White; lDisplayComponent.DisplayObject = lShape; var lPositionComponent = new PositionComponent(); lPositionComponent.X = leftX; lPositionComponent.Y = leftY; lPositionComponent.Rotation = -90; var lCollisionComponent = new CollisionComponent(); lCollisionComponent.BoundingBox = new FloatRect( leftX, leftY, Layout.OptionEntryButtonSize, Layout.OptionEntryButtonSize ); optionLeftButton.AddComponent(lDisplayComponent); optionLeftButton.AddComponent(lPositionComponent); optionLeftButton.AddComponent(lCollisionComponent); var optionRightButton = new Entity(rightName); var rDisplayComponent = new DisplayComponent(); var rShape = new CircleShape(Layout.OptionEntryButtonSize, 3); rShape.Origin = new SFML.System.Vector2f( rShape.GetLocalBounds().Width / 2, rShape.GetLocalBounds().Height / 2 ); rShape.FillColor = Color.Transparent; rShape.OutlineThickness = 3; rShape.OutlineColor = Color.White; rDisplayComponent.DisplayObject = rShape; var rPositionComponent = new PositionComponent(); rPositionComponent.X = rightX; rPositionComponent.Y = rightY; rPositionComponent.Rotation = 90; var rCollisionComponent = new CollisionComponent(); rCollisionComponent.BoundingBox = new FloatRect( rightX, rightY, Layout.OptionEntryButtonSize, Layout.OptionEntryButtonSize ); optionRightButton.AddComponent(rDisplayComponent); optionRightButton.AddComponent(rPositionComponent); optionRightButton.AddComponent(rCollisionComponent); chooseFrame.Add(textLabel); chooseFrame.Add(optionLeftButton); chooseFrame.Add(optionRightButton); chooseFrame.AddRange(textFrame); return(chooseFrame); }