Esempio n. 1
0
 public Swarmer(float _x, float _y, Color4 _color) : base(ConvexPolygon.Regular(3, 10, (float) - Math.PI / 2), _x, _y)
 {
     instinct    = new SwarmInstinct(this);
     SpeedMax    = 60;
     Speed       = 60;
     Angle       = (float)Basics.Utils.RandomAngleRad();
     angleNext   = (float)Basics.Utils.RandomAngleRad();
     color       = _color;
     BoundingBox = new BoundingBox(20, 20);
 }
Esempio n. 2
0
        public HexTile(HexGrid _grid, int _i, int _j, float _radius, Color4 _color)
        {
            grid   = _grid;
            i      = _i;
            j      = _j;
            Radius = _radius;

            Altitude = GetAltitude();
            X        = GetX();
            Y        = GetY();

            var rotationRad = grid.Horizontal ? (float)(0.5f * Math.PI) : 0;

            polygonRenderer = new PolygonFillRenderer(ConvexPolygon.Regular(6, Radius, rotationRad), X, Y, Color4.Red);
            polygonRenderer.MoveRelative(new Vector3(X, Y, 0));
        }
Esempio n. 3
0
        public override void Start()
        {
            var polygon  = ConvexPolygon.Regular(5, 100);
            var renderer = new PolygonFillRenderer(polygon, 0, 0, Color4.Blue);

            actor = new ShellActor();
            actor.UpdateHandler += () =>
            {
                var t      = MillisecondsSinceStart / 1000;
                var length = 100;
                var angle  = (Math.Sin(t) + 1.5f) * Math.PI;
                actor.X = (float)(Math.Cos(angle) * length);
                actor.Y = (float)(Math.Sin(angle) * length);
                renderer.Rotate(t * 0.01f, polygon.CenterOfMass);
            };
            actor.RenderHandler += () => renderer.Render(actor.X, actor.Y);
            actor.AddToWorld();
        }
Esempio n. 4
0
 public Particle(float _mass, int _x, int _y, int _sides = 4) : base(ConvexPolygon.Regular(_sides, GetRadius(_mass)).Move(new Vector3(_x - Game.Width / 2, _y - Game.Height / 2, 0)))
 {
     Mass        = _mass;
     Radius      = GetRadius(Mass);
     FillVisible = false;
 }