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); 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); 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.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); 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); 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() { IShape shape = ShapeFactory.CreateColoredCircle(8, 15); DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(-500, 200, 800, 800), 50, 50); Viewport viewport2 = new Viewport(new Rectangle(Window.Size.Width / 2, 0, Window.Size.Width / 2, Window.Size.Height), Matrix2x3.Identity, Scene, new Lifespan()); Window.AddViewport(viewport2); Viewport.Rectangle = new Rectangle(0, 0, Window.Size.Width / 2, Window.Size.Height); IShape furyShape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("starfury.png"), 2, 16, 3); Body b1 = DemoHelper.AddShape(DemoInfo, furyShape, 400, new ALVector2D(0, 0, 0)); Body b2 = DemoHelper.AddShape(DemoInfo, furyShape, 400, new ALVector2D(0, 0, 0)); dispose += DemoHelper.RegisterBodyTracking(DemoInfo, b1, Matrix2x3.FromRotationZ(-MathHelper.PiOver2) * Matrix2x3.FromScale(new Vector2D(.5f, .5f))); dispose += DemoHelper.RegisterBodyMovement(DemoInfo, b1, new ALVector2D(1000000, 100000, 0), Key.W, Key.S, Key.A, Key.D); DoGuns(b1, b2, Key.Q); dispose += DemoHelper.RegisterBodyTracking( new DemoOpenInfo(Window, viewport2, Scene) , b2, Matrix2x3.FromRotationZ(-MathHelper.PiOver2) * Matrix2x3.FromScale(new Vector2D(.5f, .5f))); dispose += DemoHelper.RegisterBodyMovement( DemoInfo, b2, new ALVector2D(1000000, 100000, 0)); DoGuns(b2, b1, Key.Return); b1.State.Position.Linear = new Vector2D(200, 0); b2.State.Position = new ALVector2D(MathHelper.Pi, 1, 0); b1.ApplyPosition(); b2.ApplyPosition(); DemoHelper.AddShell(DemoInfo, new BoundingRectangle(-700, -700, 1000, 1000), 90, Scalar.PositiveInfinity); dispose += delegate() { viewport2.Lifetime.IsExpired = true; Viewport.Rectangle = new Rectangle(0, 0, Window.Size.Width, Window.Size.Height); }; DemoHelper.AddStarField(DemoInfo, 1000, new BoundingRectangle(-1000, -1000, 1300, 1300)); }
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() { IShape bombShape = ShapeFactory.CreateSprite(Cache <SurfacePolygons> .GetItem("rocket.png"), 2, 16, 3); dispose += DemoHelper.RegisterBombLaunching(DemoInfo, bombShape, 120); dispose += DemoHelper.RegisterMousePicking(DemoInfo); IShape shape = ShapeFactory.CreateColoredCircle(8, 15); DemoHelper.AddGrid(DemoInfo, shape, 40, new BoundingRectangle(200, 200, 1100, 1100), 5, 5); Body b = DemoHelper.AddShape(DemoInfo, bombShape, 400, new ALVector2D(0, 0, 0)); DemoHelper.RegisterBodyTracking(DemoInfo, b, Matrix2x3.FromRotationZ(-MathHelper.PiOver2)); DemoHelper.RegisterBodyMovement(DemoInfo, b, new ALVector2D(50000, 50000, 0)); DemoHelper.AddStarField(DemoInfo, 1000, new BoundingRectangle(-1000, -1000, 2300, 2300)); }
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)); }); }