Beispiel #1
0
        private void InitGeoms()
        {
            geomA = new gxtGeom();
            geomA.CollisionEnabled = true;
            geomA.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomA.CollisionGroups = gxtCollisionGroup.ALL;
            geomA.CollisionResponseEnabled = true;
            geomA.RigidBody = null;
            geomA.Tag = null;
            gxtPolygon worldPolyA = gxtGeometry.CreateCirclePolygon(100, 9);
            geomA.Polygon = worldPolyA;
            geomA.SetPosition(new Vector2(150, -200));
            geomA.OnCollision += OnCollision;


            geomB = new gxtGeom();
            geomB.CollisionEnabled = true;
            geomB.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomB.CollisionGroups = gxtCollisionGroup.ALL;
            geomB.CollisionResponseEnabled = true;
            geomB.RigidBody = null;
            geomB.Tag = null;
            gxtPolygon worldPolyB = gxtGeometry.CreateRectanglePolygon(800, 50);
            geomB.Polygon = worldPolyB;
            geomB.SetPosition(new Vector2(0, 200));

            world.AddGeom(geomA);
            world.AddGeom(geomB);
        }
Beispiel #2
0
 private gxtGeom CreatePlatformGeom(gxtPolygon polygon, Vector2 position)
 {
     gxtGeom platGeom = new gxtGeom(polygon, true);
     gxtRigidBody platBody = new gxtRigidBody();
     platBody.MotionType = gxtRigidyBodyMotion.FIXED;
     platBody.CanSleep = false;
     platBody.Awake = true;
     platGeom.RigidBody = platBody;
     gxtPhysicsMaterial mat = new gxtPhysicsMaterial(0.6f, 0.3f);
     platGeom.CollisionGroups = world.PhysicsWorld.GetCollisionGroup("traversable_world_geometry");
     platGeom.CollidesWithGroups = world.PhysicsWorld.GetCollisionGroup("player");
     platGeom.Material = mat;
     platGeom.SetPosition(new Vector2(0.0f, 8.5f));
     world.AddGeom(platGeom);
     return platGeom;
 }
Beispiel #3
0
        private void InitGeoms()
        {
            gxtPhysicsMaterial material = new gxtPhysicsMaterial(0.7f, 0.2f);
            gxtPhysicsMaterial fMaterial = new gxtPhysicsMaterial(0.3f, 0.01f);
            gxtPhysicsMaterial cMaterial = new gxtPhysicsMaterial(0.01f, 0.5f);
            gxtPhysicsMaterial dMaterial = new gxtPhysicsMaterial(0.25f, 0.55f);

            geomA = new gxtGeom();
            geomA.CollisionEnabled = true;
            geomA.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomA.CollisionGroups = gxtCollisionGroup.ALL;
            geomA.CollisionResponseEnabled = true;
            geomA.RigidBody = null;
            geomA.Tag = null;
            //gxtPolygon worldPolyA = gxtGeometry.CreateRectanglePolygon(5.5f, 4.15f);
            //gxtPolygon worldPolyA = gxtGeometry.CreateRectanglePolygon(5.35f, 3.0f);
            gxtPolygon worldPolyA = gxtGeometry.CreateCirclePolygon(2.65f, 5);
            geomA.Polygon = worldPolyA;
            geomA.SetPosition(new Vector2(0, 0));
            //geomA.OnCollision += OnCollision;
            geomA.OnSeperation += OnSeperation;
            geomA.Material = material;

            world.PhysicsWorld.Gravity = new Vector2(0.0f, 9.8f);

            // A and B will be attached to the came rigid body
            geomB = new gxtGeom();
            geomB.CollisionEnabled = true;
            geomB.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomB.CollisionGroups = gxtCollisionGroup.ALL;
            geomB.CollisionResponseEnabled = true;
            geomB.RigidBody = null;
            geomB.Tag = null;
            //gxtPolygon worldPolyB = gxtGeometry.CreateRectanglePolygon(2.35f, 3.3f);
            gxtPolygon worldPolyB = gxtGeometry.CreateRectanglePolygon(2.35f, 5);
            geomB.SetupFromLocalPolygon(worldPolyB, new Vector2(0.0f, -4.0f), 0.0f);
            geomB.SetPosition(new Vector2(0, 0));
            geomB.Material = material;

            geomC = new gxtGeom();
            geomC.CollisionEnabled = true;
            geomC.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomC.CollisionGroups = gxtCollisionGroup.ALL;
            geomC.CollisionResponseEnabled = true;
            geomC.RigidBody = null;
            geomC.OnCollision += OnOneWayPlatformCollision;
            geomC.Tag = null;
            gxtPolygon worldPolyC = gxtGeometry.CreateRectanglePolygon(7.5f, 1.35f);
            geomC.Polygon = worldPolyC;
            geomC.SetPosition(new Vector2(4.5f, 5.25f));
            geomC.Material = cMaterial;

            geomD = new gxtGeom();
            geomD.CollisionEnabled = true;
            geomD.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomD.CollisionGroups = gxtCollisionGroup.ALL;
            geomD.CollisionResponseEnabled = true;
            geomD.RigidBody = null;
            geomD.Tag = null;
            gxtPolygon worldPolyD = gxtGeometry.CreateRectanglePolygon(3.0f, 3.0f);
            geomD.Polygon = worldPolyD;
            geomD.Material = dMaterial;
            //geomD.SetPosition(new Vector2(400, 0));

            /*
            geomE = new gxtGeom();
            geomE.CollisionEnabled = true;
            geomE.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomE.CollisionGroups = gxtCollisionGroup.ALL;
            geomE.CollisionResponseEnabled = true;
            geomE.RigidBody = null;
            geomE.Tag = null;
            gxtPolygon worldPolyE;
            Vector2[] tri = new Vector2[3];
            tri[0] = new Vector2(-400, -300);
            tri[1] = new Vector2(400, -75);
            tri[2] = new Vector2(400, -300);
            worldPolyE = new gxtPolygon(tri);
            geomE.Polygon = worldPolyE;
            geomE.SetPosition(new Vector2(0, 0));
            */

            geomF = new gxtGeom();
            geomF.CollisionEnabled = true;
            geomF.CollidesWithGroups = gxtCollisionGroup.ALL;
            geomF.CollisionGroups = gxtCollisionGroup.ALL;
            geomF.CollisionResponseEnabled = true;
            geomF.RigidBody = null;
            geomF.Tag = null;
            //geomF.Polygon = gxtGeometry.CreateCirclePolygon(2.0f, 12);
            geomF.Polygon = gxtGeometry.CreateRectanglePolygon(3.0f, 4.5f);
            //geomF.Polygon = gxtGeometry.CreateRectanglePolygon(4.35f, 4);
            geomF.SetPosition(new Vector2(-5.5f, -3.15f));
            geomF.OnCollision += OnCollision;
            geomF.Material = fMaterial;

            floorG = new gxtGeom();
            floorG.CollisionEnabled = true;
            floorG.CollidesWithGroups = gxtCollisionGroup.ALL;
            floorG.CollisionGroups = gxtCollisionGroup.ALL;
            floorG.CollisionResponseEnabled = true;
            floorG.RigidBody = null;
            floorG.Tag = null;
            floorG.Polygon = gxtGeometry.CreateRectanglePolygon(30, 2.5f);
            floorG.SetPosition(new Vector2(0.0f, 10.25f));
            floorG.Material = material;

            world.AddGeom(geomA);
            world.AddGeom(floorG);
            //world.AddGeom(geomB);

            world.AddGeom(geomC);
            world.AddGeom(geomD);
            /*
            world.AddGeom(geomE);
            */
            world.AddGeom(geomF);
        }
Beispiel #4
0
        private void InitGeoms()
        {
            geoms = new List<gxtGeom>();

            playerGeom = new gxtGeom();
            playerGeom.CollisionEnabled = true;
            playerGeom.CollidesWithGroups = gxtCollisionGroup.ALL;
            playerGeom.CollisionGroups = gxtCollisionGroup.ALL;
            playerGeom.CollisionResponseEnabled = true;
            playerGeom.RigidBody = null;
            playerGeom.Tag = null;
            gxtPolygon worldPolyA = gxtGeometry.CreateCirclePolygon(100, 9);
            playerGeom.Polygon = worldPolyA;
            playerGeom.SetPosition(new Vector2(150, -200));
            playerGeom.OnCollision += OnCollision;

            gxtGeom floorGeom = new gxtGeom();
            floorGeom.CollisionEnabled = true;
            floorGeom.CollidesWithGroups = gxtCollisionGroup.ALL;
            floorGeom.CollisionGroups = gxtCollisionGroup.ALL;
            floorGeom.CollisionResponseEnabled = true;
            floorGeom.RigidBody = null;
            floorGeom.Tag = null;
            gxtPolygon floorPoly = gxtGeometry.CreateRectanglePolygon(750, 30);
            floorGeom.Polygon = floorPoly;
            floorGeom.SetPosition(new Vector2(0, 200));
            floorGeom.OnCollision += OnCollision;
            floorGeom.Material = new gxtPhysicsMaterial(0.7f, 0.5f);

            world.AddGeom(playerGeom);
            world.AddGeom(floorGeom);
            geoms.Add(floorGeom);
        }