예제 #1
0
        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);


            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));

            List <Body> chain = DemoHelper.AddChain(DemoInfo, new Vector2D(400, 50), 100, 30, 200, 20, 800);
            Vector2D    point = new Vector2D(300, 50);

            Body Anchor = DemoHelper.AddCircle(DemoInfo, 30, 18, Scalar.PositiveInfinity, new ALVector2D(0, point));

            Anchor.IgnoresGravity = true;
            HingeJoint joint = new HingeJoint(chain[0], Anchor, point, new Lifespan());

            joint.DistanceTolerance = 10;
            Scene.Engine.AddJoint(joint);
        }
예제 #2
0
        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);
            dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0));


            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));

            IShape shape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("block.png"), 3, 7, 4);

            DemoHelper.AddGrid(
                DemoInfo, shape, 20,
                new BoundingRectangle(400, 200, 500, 510),
                50, 2);


            Scalar      boxlength    = 50;
            Scalar      spacing      = 4;
            Scalar      anchorLenght = 30;
            Scalar      anchorGap    = (boxlength / 2) + spacing + (anchorLenght / 2);
            List <Body> chain        = DemoHelper.AddChain(DemoInfo, new Vector2D(200, 500), boxlength, 20, 200, spacing, 600);

            Vector2D point2 = new Vector2D(chain[chain.Count - 1].State.Position.Linear.X + anchorGap, 500);
            Body     end2   = DemoHelper.AddCircle(DemoInfo, anchorLenght / 2, 14, Scalar.PositiveInfinity, new ALVector2D(0, point2));

            end2.IgnoresGravity = true;
            HingeJoint joint2 = new HingeJoint(chain[chain.Count - 1], end2, point2, new Lifespan());

            joint2.DistanceTolerance = 10;
            Scene.Engine.AddJoint(joint2);

            Vector2D point1 = new Vector2D(chain[0].State.Position.Linear.X - anchorGap, 500);
            Body     end1   = DemoHelper.AddCircle(DemoInfo, anchorLenght / 2, 14, Scalar.PositiveInfinity, new ALVector2D(0, point1));

            end1.IgnoresGravity = true;
            HingeJoint joint1 = new HingeJoint(chain[0], end1, point1, new Lifespan());

            joint1.DistanceTolerance = 10;
            Scene.Engine.AddJoint(joint1);
            end2.State.Position.Linear.X -= 10;
            end1.State.Position.Linear.X += 10;
            end2.ApplyPosition();
            end1.ApplyPosition();
        }