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; }
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; }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new GravityPointField(new Vector2D(500, 500), 1000, new Lifespan())); Light light = new Light(); light.Position.X = 000; light.Position.Y = 000; light.Position.Z = 0100; Body lightBody = new Body(new PhysicsState(), ShapeFactory.CreateCircle(15, 20), 40, new Coefficients(0, 1), new Lifespan()); BodyGraphic lightGraphic = new BodyGraphic(lightBody); lightGraphic.DrawProperties.Add(new Color3Property(1, 1, 1)); Scene.AddGraphic(lightGraphic); lightBody.PositionChanged += delegate(object sender, EventArgs e) { light.Position = lightBody.State.Position.Linear.ToVector3D(100); }; IShape shape = ShapeFactory.CreateSprite( Cache <SurfacePolygons> .GetItem("Monkey.png"), Cache <Surface> .GetItem("MonkeyNormal.bmp"), false, true, 3, 8, 16, light); DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(40, 40, 900, 900), 100, 100); }
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); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); IShape shape = ShapeFactory.CreateColoredCircle(8, 15); DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(-200, -200, 1100, 1100), 5, 5); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); IShape shape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("block.png"), 3, 7, 4); DemoHelper.AddGrid(DemoInfo, shape, 400, new BoundingRectangle(-200, -200, 1100, 1100), 5, 5); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new LineFluidLogic(new Line(0, -1, -400), 1.95f, .02f, new Vector2D(0, 0), new Lifespan())); Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); Rectangle rect1 = Viewport.Rectangle; BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom); rect.Min.X -= 75; rect.Min.Y -= 75; rect.Max.X += 75; rect.Max.Y += 75; DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; }); DemoHelper.AddRagDoll(DemoInfo, new Vector2D(340, 300)); DemoHelper.AddRagDoll(DemoInfo, new Vector2D(640, 300)); IShape shape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("fighter.png"), 3, 16, 4); DemoHelper.AddShape(DemoInfo, shape, 200, new ALVector2D(0, new Vector2D(200, 300))); DemoHelper.AddShape(DemoInfo, shape, 100, new ALVector2D(0, new Vector2D(500, 300))); DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 600)); DemoHelper.AddRectangle(DemoInfo, 20, 200, 25 / 5, new ALVector2D(0, 600, 620)); DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 200, 400)); DemoHelper.AddRectangle(DemoInfo, 50, 100, 50, new ALVector2D(0, 400, 200)); Vector2D[] waterVertexes = new Vector2D[4] { new Vector2D(-10, 400), new Vector2D(10000, 400), new Vector2D(10000, 1000), new Vector2D(-10, 1000) }; ScalarColor3[] waterColor = new ScalarColor3[4] { new ScalarColor3(0, 0, 1), new ScalarColor3(0, 0, 1), new ScalarColor3(0, 0, 1), new ScalarColor3(0, 0, 1) }; Colored3VertexesDrawable drawable = new Colored3VertexesDrawable(Gl.GL_QUADS, waterVertexes, waterColor); Graphic graphic = new Graphic(drawable, Matrix2x3.Identity, new Lifespan()); graphic.ZOrder = -1; Scene.AddGraphic(graphic); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); IShape shape = ShapeFactory.CreateColoredCircle(8, 15); List <Body> bodies = DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(100, 100, 600, 600), 40, 40); MoveToPointLogic logic = null; dispose += DemoHelper.RegisterSpawning(this.DemoInfo, SdlDotNet.Input.Key.H, delegate(Vector2D position) { if (logic != null) { logic.Lifetime.IsExpired = true; } logic = new MoveToPointLogic(bodies[0], position, 90, 200000); this.DemoInfo.Scene.Engine.AddLogic(logic); return(logic); }); List <MoveToPointLogic> logics = new List <MoveToPointLogic>(); dispose += DemoHelper.RegisterSpawning(this.DemoInfo, SdlDotNet.Input.Key.J, delegate(Vector2D position) { foreach (MoveToPointLogic logic2 in logics) { logic2.Lifetime.IsExpired = true; } logics.Clear(); Vector2D center = Vector2D.Zero; foreach (Body body in bodies) { center += body.State.Position.Linear; } center *= (1f / (Scalar)bodies.Count); foreach (Body body in bodies) { MoveToPointLogic logic2 = new MoveToPointLogic(body, position + body.State.Position.Linear - center, 90000, Scalar.MaxValue, true, new Lifespan()); logics.Add(logic2); this.DemoInfo.Scene.Engine.AddLogic(logic2); } return(null); }); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Vector2D gravityCenter = new Vector2D(500, 500); Scalar gravityPower = 200; Scene.Engine.AddLogic(new GravityPointField(gravityCenter, gravityPower, new Lifespan())); DemoHelper.AddRagDoll(DemoInfo, gravityCenter + new Vector2D(0, -20)); Scalar length = 41; Scalar size = 8 ; bool reverse = false; for (Scalar distance = 250; distance < 650; length += 10, size *= 2, distance += 60 + length) { Scalar da = MathHelper.TwoPi / size;// ((MathHelper.TWO_PI * distance) / size); Scalar l2 = length / 2; // da /= 2; Vector2D[] vertexes = new Vector2D[] { Vector2D.FromLengthAndAngle(distance - l2, da / 2), Vector2D.FromLengthAndAngle(distance - l2, -da / 2), Vector2D.FromLengthAndAngle(distance + l2, -da / 2), Vector2D.FromLengthAndAngle(distance + l2, da / 2), }; //da *= 2; Vector2D[] vertexes2 = VertexHelper.CenterVertexes(vertexes); vertexes = VertexHelper.Subdivide(vertexes2, 5); PolygonShape shape = ShapeFactory.CreateColoredPolygon(vertexes, 1.5f); for (Scalar angle = 0; angle < MathHelper.TwoPi; angle += da) { Vector2D position = Vector2D.FromLengthAndAngle(distance, angle) + gravityCenter; Body body = DemoHelper.AddShape(DemoInfo, shape, (size * length) / 10, new ALVector2D(angle, position)); body.State.Velocity.Linear = DemoHelper.GetOrbitVelocity(gravityCenter, Vector2D.FromLengthAndAngle(distance - length, angle) + gravityCenter, gravityPower); body.State.Velocity.Linear *= .5f; body.State.Velocity.Angular = -(body.State.Velocity.Linear.Magnitude) / (distance);// *(1 / MathHelper.TWO_PI); if (reverse) { body.State.Velocity.Linear = -body.State.Velocity.Linear; body.State.Velocity.Angular = -body.State.Velocity.Angular; } } reverse = !reverse; } }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Scene.Engine.AddLogic(new GravityField(new Vector2D(0, 1000), new Lifespan())); SurfacePolygons surfacePolygons = Cache <SurfacePolygons> .GetItem("physicsplayGround.png"); foreach (Vector2D[] vertexes in surfacePolygons.Polygons) { Vector2D[] processed = vertexes; for (int index = 1; index < 4; index++) { processed = VertexHelper.Reduce(processed, index); } processed = VertexHelper.Subdivide(processed, 16); IShape shape = ShapeFactory.CreateColoredPolygon(processed, 10); DemoHelper.AddShape(DemoInfo, shape, Scalar.PositiveInfinity, new ALVector2D(0, surfacePolygons.Offset)).IgnoresGravity = true; } for (int x = 440; x < 480; x += 10) { for (int y = -2000; y < 0; y += 12) { Body body = DemoHelper.AddCircle(DemoInfo, 5, 7, 3, new ALVector2D(0, x + DemoHelper.NextScalar(-400, 400), y)); body.Updated += delegate(object sender, UpdatedEventArgs e) { if (body.State.Position.Linear.Y > 900) { body.State.Position.Linear.Y = -100; } }; } } for (int x = 490; x < 510; x += 10) { for (int y = -550; y < -500; y += 12) { Body body = DemoHelper.AddRectangle(DemoInfo, 10, 20, 10, new ALVector2D(0, x + DemoHelper.NextScalar(-400, 400), y)); body.Updated += delegate(object sender, UpdatedEventArgs e) { if (body.State.Position.Linear.Y > 900) { body.State.Position.Linear.Y = -100; } }; } } }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); DemoHelper.AddText(DemoInfo, @"WELCOME TO THE PHYSICS2D.NET DEMO. PLEASE ENJOY MESSING WITH IT. A LOT OF HARD WORK WENT INTO IT, SO THAT YOU COULD ENJOY IT. PLEASE SEND FEEDBACK. EACH CHARACTER HERE IS AN ACTUAL BODY IN THE ENGINE. THIS IS TO SHOW OFF THE BITMAP TO POLYGON ALGORITHM." , new Vector2D(20, 20), 40); }
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)); }
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))); }
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); }
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)); }
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(); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); IShape fighterShape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("fighter.png"), 4, 50, 5); Body fighter = new Body(new PhysicsState(new ALVector2D(0, 300, 300)), fighterShape, 5000, new Coefficients(0, 1), new Lifespan()); fighter.State.Velocity.Angular = 9; fighter.Mass.MomentOfInertia = Scalar.PositiveInfinity; BodyGraphic fighterGraphic = new BodyGraphic(fighter); Scene.AddGraphic(fighterGraphic); BodyGraphic fighterGraphic2 = (BodyGraphic)fighterGraphic.Duplicate(); fighterGraphic2.Body.State.Position.Linear.Y = 500; fighterGraphic2.Body.State.Velocity.Angular = -8.5f; Scene.AddGraphic(fighterGraphic2); Body template2 = new Body(new PhysicsState(new ALVector2D(0, 200, 200)), ParticleShape.Default, 4, new Coefficients(0, 1), new Lifespan()); Matrix2x3 m = Matrix2x3.FromRotationZ(2); int count = 0; for (int x = -0; x < 1000; x += 25) { for (int y = -0; y < 1000; y += 25) { count++; Body body = template2.Duplicate(); body.State.Position.Linear = new AdvanceMath.Vector2D(x, y); body.ApplyPosition(); body.State.Velocity.Linear.X = (250 - x) / 10f; body.State.Velocity.Linear.Y = (250 - y) / 10f; body.State.Velocity.Linear = m * body.State.Velocity.Linear; body.LinearDamping = .9999f; BodyGraphic g1 = new BodyGraphic(body); Scene.AddGraphic(g1); } } Scene.Engine.AddLogic(new GravityPointField(new Vector2D(400, 400), 500, new Lifespan())); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); dispose += DemoHelper.CreateTank(DemoInfo, new Vector2D(50, 0)); Scene.Engine.AddLogic(new GravityPointField(new Vector2D(500, 400), 1000, new Lifespan())); IShape shape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("block.png"), 3, 7, 4); for (int index = 0; index < 5; index++) { Vector2D pos = new Vector2D(500, 500) + Vector2D.FromLengthAndAngle(500, .6f * index); DemoHelper.AddRagDoll(DemoInfo, pos); } DemoHelper.AddGrid( DemoInfo, shape, 20, new BoundingRectangle(400, 400, 800, 710), 5, 4); }
protected override void Open() { dispose += DemoHelper.BasicDemoSetup(DemoInfo); Rectangle rect1 = Viewport.Rectangle; BoundingRectangle rect = new BoundingRectangle(rect1.Left, rect1.Top, rect1.Right, rect1.Bottom); rect.Min.X -= 75; rect.Min.Y -= 75; rect.Max.X += 75; rect.Max.Y += 75; DemoHelper.AddShell(DemoInfo, rect, 100, Scalar.PositiveInfinity).ForEach(delegate(Body b) { b.IgnoresGravity = true; }); rect.Min.X += 110; rect.Min.Y += 110; rect.Max.X -= 110; rect.Max.Y -= 110; IShape shape = ShapeFactory.CreateColoredCircle(3, 7); DemoHelper.AddGrid(DemoInfo, shape, 40, rect, 1, 1).ForEach(delegate(Body b) { b.State.Velocity.Linear = new Vector2D(DemoHelper.Rand.Next(-100, 100), DemoHelper.Rand.Next(-100, 100)); }); }
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; }