コード例 #1
0
        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);
            dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0));
            List <Body> bodies = new List <Body>();

            dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(250, 0), bodies);

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

            DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750)));

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

            for (int i = 128 * 3; i > -128; i -= 128)
            {
                Body b = DemoHelper.AddShape(DemoInfo, shape, 40, new ALVector2D(1, new Vector2D(700, 272 + i)));
                //b.Transformation *= Matrix2x3.FromScale(new Vector2D(1, .5f));
            }

            Body line = DemoHelper.AddLine(DemoInfo, new Vector2D(300, 400), new Vector2D(600, 400), 20, Scalar.PositiveInfinity);

            line.IgnoresGravity = true;
            GroupedOneWayPlatformIgnorer ignorer = new GroupedOneWayPlatformIgnorer(-Vector2D.YAxis, 10);

            ignorer.AddGroup(bodies.ToArray());
            line.CollisionIgnorer = ignorer;

            Body ball = DemoHelper.AddCircle(DemoInfo, 80, 20, 4000, new ALVector2D(0, 1028, 272));

            ball.Transformation *=
                Matrix2x3.FromRotationZ(1) *
                Matrix2x3.FromScale(new Vector2D(.9f, .5f)) *
                Matrix2x3.FromRotationZ(-1);
        }
コード例 #2
0
        protected override void Open()
        {
            Scene.IsPaused = true;
            List <Body> bodies = new List <Body>();

            Body b = DemoHelper.AddLine(DemoInfo, new Vector2D(300, 200), new Vector2D(400, 200), 40, Scalar.PositiveInfinity);

            b.IgnoresPhysicsLogics = true;
            bodies.Add(b);
            Body b2 = DemoHelper.AddCircle(DemoInfo, 20, 40, Scalar.PositiveInfinity, new ALVector2D(0, 300, 100));

            b2.IgnoresPhysicsLogics = true;
            bodies.Add(b2);
            Body b3 = DemoHelper.AddCircle(DemoInfo, 20, 40, 50, new ALVector2D(0, 100, 100));

            bodies.Add(b3);
            Body b4 = DemoHelper.AddRectangle(DemoInfo, 20, 20, 20, new ALVector2D(0, 150, 150));

            bodies.Add(b4);

            dispose += RegisterDup(DemoInfo, bodies);

            DemoHelper.AddShell(DemoInfo, new BoundingRectangle(0, 0, 200, 200), 10, Scalar.PositiveInfinity).ForEach(delegate(Body sb) { sb.IgnoresPhysicsLogics = true; });



            Body bStart = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("start.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 650));

            // Body bStart = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 600), new Vector2D(100, 600), 40, Scalar.PositiveInfinity);
            bStart.IgnoresPhysicsLogics = true;
            Body bStop = DemoHelper.AddShape(DemoInfo, ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("stop.png"), 2, 16, 3), Scalar.PositiveInfinity, new ALVector2D(0, 100, 700));

            //Body bEnd = DemoHelper.AddLine(DemoInfo, new Vector2D(10, 700), new Vector2D(100, 700), 40, Scalar.PositiveInfinity);
            bStop.IgnoresPhysicsLogics = true;

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

            dispose += DemoHelper.RegisterClick(DemoInfo, bStart, MouseButton.PrimaryButton,
                                                delegate(object sender, EventArgs e)
            {
                Scene.IsPaused = false;
            });
            dispose += DemoHelper.RegisterClick(DemoInfo, bStop, MouseButton.PrimaryButton,
                                                delegate(object sender, EventArgs e)
            {
                Scene.IsPaused = true;
            });
        }
コード例 #3
0
ファイル: RagdollDemo.cs プロジェクト: wyb314/Physics2D.Net
 protected override void Open()
 {
     dispose += DemoHelper.BasicDemoSetup(DemoInfo);
     dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(300, 0));
     Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));
     DemoHelper.AddLine(DemoInfo, new Vector2D(0, 700), new Vector2D(300, 700), 30, Scalar.PositiveInfinity).IgnoresGravity   = true;
     DemoHelper.AddLine(DemoInfo, new Vector2D(300, 700), new Vector2D(400, 650), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
     DemoHelper.AddLine(DemoInfo, new Vector2D(400, 650), new Vector2D(500, 650), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
     DemoHelper.AddLine(DemoInfo, new Vector2D(500, 650), new Vector2D(500, 500), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
     DemoHelper.AddLine(DemoInfo, new Vector2D(500, 500), new Vector2D(900, 550), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
     DemoHelper.AddLine(DemoInfo, new Vector2D(400, 400), new Vector2D(600, 300), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(200, 400));
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(300, 300));
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(400, 200));
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(500, 100));
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(600, 0));
     DemoHelper.AddRagDoll(DemoInfo, new Vector2D(700, -100));
 }
コード例 #4
0
        protected override void Open()
        {
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);


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

            for (int x = 0; x < 400; x += 45)
            {
                DemoHelper.AddRectangle(DemoInfo, 80, 15, 90, new ALVector2D(0, x, 145));
            }

            DemoHelper.AddLine(DemoInfo, new Vector2D(-40, 200), new Vector2D(400, 200), 30, Scalar.PositiveInfinity).IgnoresGravity = true;

            DemoHelper.AddLine(DemoInfo, new Vector2D(400, 150), new Vector2D(430, 150), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
            DemoHelper.AddLine(DemoInfo, new Vector2D(430, 150), new Vector2D(600, 200), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
            DemoHelper.AddLine(DemoInfo, new Vector2D(600, 200), new Vector2D(700, 300), 30, Scalar.PositiveInfinity).IgnoresGravity = true;

            DemoHelper.AddLine(DemoInfo, new Vector2D(1200, 200), new Vector2D(800, 420), 30, Scalar.PositiveInfinity).IgnoresGravity = true;
            DemoHelper.AddLine(DemoInfo, new Vector2D(800, 420), new Vector2D(700, 470), 30, Scalar.PositiveInfinity).IgnoresGravity  = true;
            DemoHelper.AddLine(DemoInfo, new Vector2D(700, 470), new Vector2D(600, 486), 30, Scalar.PositiveInfinity).IgnoresGravity  = true;
            DemoHelper.AddLine(DemoInfo, new Vector2D(600, 486), new Vector2D(570, 486), 30, Scalar.PositiveInfinity).IgnoresGravity  = true;

            Scalar rest = DemoHelper.Coefficients.Restitution;

            DemoHelper.Coefficients.Restitution = 1;
            DemoHelper.AddCircle(DemoInfo, 20, 20, 300, new ALVector2D(0, 409, 115));


            for (int x = 160; x < 500; x += 42)
            {
                Body b = DemoHelper.AddCircle(DemoInfo, 20, 20, 300, new ALVector2D(0, x, 450));
                Scene.Engine.AddJoint(new FixedHingeJoint(b, b.State.Position.Linear - new Vector2D(0, 500), new Lifespan()));
            }
            DemoHelper.Coefficients.Restitution = rest;
        }