Esempio n. 1
0
        protected override void Open()
        {
            Coefficients coefficients = DemoHelper.Coefficients;

            DemoHelper.Coefficients.Restitution = 0;

            dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0));
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);

            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));
            DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750)));

            IShape piston = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("piston.png"), 0, 16, 1);
            IShape socket = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("socket.png"), 0, 16, 1);

            DemoHelper.AddShape(DemoInfo, piston, 10, new ALVector2D(0, 300, 300));
            DemoHelper.AddShape(DemoInfo, socket, 10, new ALVector2D(0, 300, 300));

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

            DemoHelper.AddShape(DemoInfo, fighter, 50, new ALVector2D(0, 500, 300));
            DemoHelper.AddShape(DemoInfo, fighter, 50, new ALVector2D(0, 500, 100));

            IShape starfury = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("Starfury.png"), 3, 16, 3);

            DemoHelper.AddShape(DemoInfo, starfury, 50, new ALVector2D(0, 700, 300));
            DemoHelper.AddShape(DemoInfo, starfury, 50, new ALVector2D(0, 700, 100));


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

            DemoHelper.Coefficients = coefficients;
        }
Esempio n. 2
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);
        }
Esempio n. 3
0
        protected override void Open()
        {
            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));
            IShape bombShape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("rocket.png"), 2, 16, 3);

            dispose += DemoHelper.BasicDemoSetup(DemoInfo);



            Coefficients o = DemoHelper.Coefficients;

            DemoHelper.Coefficients = new Coefficients(1, .5f);
            DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750)));
            Body b1 = DemoHelper.AddRectangle(DemoInfo, 750, 100, Scalar.PositiveInfinity, new ALVector2D(0, 0, 750 / 2));

            b1.IgnoresGravity = true;
            Body b2 = DemoHelper.AddRectangle(DemoInfo, 750, 100, Scalar.PositiveInfinity, new ALVector2D(0, 1024, 750 / 2));

            b2.IgnoresGravity       = true;
            DemoHelper.Coefficients = new Coefficients(.7f, .05f);


            for (int x = 60; x < 80; x += 10)
            {
                for (int y = -2000; y < 700; y += 12)
                {
                    Body g = DemoHelper.AddCircle(DemoInfo, 5, 7, 3, new ALVector2D(0, x, y));
                    g.State.Velocity.Angular = 1;
                    //  g.State.Velocity.Linear = new Vector2D(0, 500);
                }
            }
            DemoHelper.Coefficients = o;
        }
Esempio n. 4
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()));


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

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


            DemoHelper.AddGrid(
                DemoInfo, shape, 20,
                new BoundingRectangle(440, 450, 500, 730),
                1, 1);
            Body ball = DemoHelper.AddCircle(DemoInfo, 80, 20, 4000, new ALVector2D(0, 1028, 272));

            Vector2D[][] polygons1 = new Vector2D[2][];
            polygons1[0] = VertexHelper.Subdivide(VertexHelper.CreateRectangle(50, 50), 16);
            polygons1[1] = VertexHelper.CreateCircle(30, 20);
            Matrix2x3 matrix = Matrix2x3.FromTransformation(1, new Vector2D(30, 50));

            polygons1[0] = VertexHelper.ApplyMatrix(ref matrix, polygons1[0]);

            IShape shape1 = ShapeFactory.CreateColoredMultiPolygon(polygons1, 3);

            DemoHelper.AddShape(DemoInfo, shape1, 50, new ALVector2D(0, 300, 300));


            Vector2D[][] polygons = new Vector2D[3][];
            polygons[0] = VertexHelper.Subdivide(VertexHelper.CreateRectangle(30, 50), 16);
            polygons[1] = VertexHelper.Subdivide(VertexHelper.CreateRectangle(50, 70), 16);
            polygons[2] = VertexHelper.CreateCircle(30, 20);
            matrix      = Matrix2x3.FromTransformation(6, new Vector2D(36, 50));

            polygons[2] = VertexHelper.ApplyMatrix(ref matrix, polygons[2]);
            matrix      = Matrix2x3.FromTransformation(-6, new Vector2D(-36, 50));

            polygons[1] = VertexHelper.ApplyMatrix(ref matrix, polygons[1]);
            IShape shape2 = ShapeFactory.CreateColoredMultiPolygon(polygons, 3);

            DemoHelper.AddShape(DemoInfo, shape2, 50, new ALVector2D(0, 400, 300));
        }
Esempio n. 5
0
        protected override void Open()
        {
            dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0));
            dispose += DemoHelper.BasicDemoSetup(DemoInfo);

            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("block.png"), 3, 7, 4);


            DemoHelper.AddGrid(
                DemoInfo, shape, 20,
                new BoundingRectangle(300, 500, 900, 710),
                50, 2);

            Body ball = DemoHelper.AddCircle(DemoInfo, 80, 20, 4000, new ALVector2D(0, 1028, 272));// //AddShape(new CircleShape(80, 20), 4000, new ALVector2D(0, new Vector2D(1028, 272)));
        }
Esempio n. 6
0
        protected override void Open()
        {
            Coefficients coefficients = DemoHelper.Coefficients;

            DemoHelper.Coefficients.Restitution = 0;


            Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan()));
            DemoHelper.AddFloor(DemoInfo, new ALVector2D(0, new Vector2D(700, 750)));

            int canJump = 0;


            IShape fighter = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("fighter.png"), 3, 16, 3);
            Body   body    = DemoHelper.AddShape(DemoInfo, fighter, 50, new ALVector2D(0, 500, 300));

            body.Mass.MomentOfInertia = Scalar.PositiveInfinity;

            Scalar desiredVelocity = 0;
            Scalar maxVelocity     = 150;

            body.Collided += delegate(object sender, CollisionEventArgs e)
            {
                canJump++;
                e.Contact.Ended += delegate(object sender2, EventArgs e2)
                {
                    canJump--;
                };
            };
            EventHandler <KeyboardEventArgs> keyDownHandler = delegate(object sender, KeyboardEventArgs e)
            {
                if (canJump > 0 && e.Key == Key.UpArrow)
                {
                    body.State.ForceAccumulator.Linear.Y -= 50 * 60000;
                }

                if (e.Key == Key.RightArrow)
                {
                    desiredVelocity += maxVelocity;
                }
                else if (e.Key == Key.LeftArrow)
                {
                    desiredVelocity -= maxVelocity;
                }
            };
            EventHandler <KeyboardEventArgs> keyUpHandler = delegate(object sender, KeyboardEventArgs e)
            {
                if (e.Key == Key.RightArrow)
                {
                    desiredVelocity -= maxVelocity;
                }
                else if (e.Key == Key.LeftArrow)
                {
                    desiredVelocity += maxVelocity;
                }
            };

            body.Updated += delegate(object sender, UpdatedEventArgs e)
            {
                if (canJump > 0)
                {
                    if (desiredVelocity < 0)
                    {
                        if (desiredVelocity < body.State.Velocity.Linear.X)
                        {
                            body.State.ForceAccumulator.Linear.X -= 50 * 6000;
                        }
                    }
                    if (desiredVelocity > 0)
                    {
                        if (desiredVelocity > body.State.Velocity.Linear.X)
                        {
                            body.State.ForceAccumulator.Linear.X += 50 * 6000;
                        }
                    }
                }
            };

            DemoHelper.AddRectangle(DemoInfo, 40, 300, 200, new ALVector2D(0, 200, 600));
            DemoHelper.AddRectangle(DemoInfo, 40, 300, 200, new ALVector2D(0, 400, 400));
            DemoHelper.AddRectangle(DemoInfo, 40, 40, 20, new ALVector2D(0, 100, 100));
            DemoHelper.AddRectangle(DemoInfo, 40, 40, 20, new ALVector2D(0, 200, 200));
            DemoHelper.AddRectangle(DemoInfo, 40, 40, 20, new ALVector2D(0, 300, 300));
            DemoHelper.AddRagDoll(DemoInfo, new Vector2D(700, 300));


            Events.KeyboardDown += keyDownHandler;
            Events.KeyboardUp   += keyUpHandler;
            dispose             += delegate()
            {
                Events.KeyboardDown -= keyDownHandler;
                Events.KeyboardUp   -= keyUpHandler;
            };
            DemoHelper.Coefficients = coefficients;
        }