Beispiel #1
0
        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);

        }
Beispiel #2
0
 private BodyGraphic(BodyGraphic copy)
     : base(copy)
 {
     SetBody(copy.body.Duplicate());
     this.Lifetime    = body.Lifetime;
     this.isBodyOwner = copy.isBodyOwner;
 }
 public void OnPending(Graphic parent)
 {
     this.parent = parent as BodyGraphic;
     logic = new RaySegmentsCollisionLogic(this.parent.Body);
     parent.Parent.physicsLogics.Add(logic);
     logic.NewInfo += logic_NewInfo;
 }
Beispiel #4
0
 private BodyGraphic(BodyGraphic copy)
     : base(copy)
 {
     SetBody(copy.body.Duplicate());
     this.Lifetime = body.Lifetime;
     this.isBodyOwner = copy.isBodyOwner;
 }
 public void OnPending(Graphic parent)
 {
     this.parent = parent as BodyGraphic;
     logic       = new RaySegmentsCollisionLogic(this.parent.Body);
     parent.Parent.physicsLogics.Add(logic);
     logic.NewInfo += logic_NewInfo;
 }
Beispiel #6
0
            void clipper_Collided(object sender, CollisionEventArgs e)
            {
                BodyGraphic graphic = e.Other.Tag as BodyGraphic;

                if (graphic != null)
                {
                    graphic.SetCollidedStep(e.Step.UpdateCount);
                }
            }
        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()));

        }
Beispiel #8
0
 public static BodyGraphic CreateGraphic(Body body)
 {
     BodyGraphic result = new BodyGraphic(body);
     result.DrawProperties.Add(new StateColorProperty(body));
     return result;
 }