コード例 #1
0
ファイル: Demo4.cs プロジェクト: rbrother/seikkailulaakso
        public override void Initialize()
        {
            ClearCanvas();
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 100));
            physicsSimulator.BiasFactor = .4f;
            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth + borderWidth*2, ScreenManager.ScreenHeight + borderWidth*2,
                                 borderWidth, ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);
            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, 32, 32, 1f);
            _rectangleGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _rectangleBody, 32, 32);
            _rectangleGeom.FrictionCoefficient = .4f;
            _rectangleGeom.RestitutionCoefficient = 0f;

            //create the pyramid near the bottom of the screen.
            _pyramid = new Pyramid(_rectangleBody, _rectangleGeom, 32f/3f, 32f/3f, 32, 32, _pyramidBaseBodyCount,
                                   new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount*.5f*(32 + 32/3),
                                               ScreenManager.ScreenHeight - 125));
            _pyramid.Load(this, physicsSimulator);

            _floor = new Floor(ScreenManager.ScreenWidth, 100,
                               new Vector2(ScreenManager.ScreenCenter.X, ScreenManager.ScreenHeight - 50));
            _floor.Load(this, physicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter - new Vector2(320, 300));
            _agent.Load(this, physicsSimulator);
            controlledBody = _agent.Body;
            base.Initialize();
        }
コード例 #2
0
ファイル: Demo7.cs プロジェクト: rbrother/seikkailulaakso
        public override void Initialize()
        {
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 150));
            PhysicsSimulator.MaxContactsToDetect = 5;
            physicsSimulator.MaxContactsToResolve = 2;
            physicsSimulator.Iterations = 10;
            physicsSimulator.BiasFactor = .4f;

            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth, ScreenManager.ScreenHeight, borderWidth,
                                 ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter - new Vector2(200, 0));
            _agent.CollisionCategory = CollisionCategory.Cat5;
            _agent.CollidesWith = CollisionCategory.All & ~CollisionCategory.Cat4; //collide with all but Cat5(black)
            _agent.Load(this, physicsSimulator);
            _agent.Body.LinearDragCoefficient = .001f;
            controlledBody = _agent.Body;
            AddAgentToCanvas(_agent.Body);
            LoadSpiders();
            base.Initialize();
        }
コード例 #3
0
ファイル: Demo6.cs プロジェクト: rbrother/seikkailulaakso
        public override void Initialize()
        {
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 200));
            PhysicsSimulator.MaxContactsToDetect = 2;
            //for stacked objects, simultaneous collision are the bottlenecks so limit them to 2 per geometric pair.
            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth + borderWidth*2, ScreenManager.ScreenHeight + borderWidth*2,
                                 borderWidth, ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);

            _agent = new Agent(new Vector2(ScreenManager.ScreenCenter.X, 100));
            _agent.CollisionCategory = CollisionCategory.Cat5;
            _agent.CollidesWith = CollisionCategory.All & ~CollisionCategory.Cat4; //collide with all but Cat5(black)
            _agent.Load(this, physicsSimulator);
            AddAgentToCanvas(_agent.Body);
            LoadPlatforms();
            controlledBody = _agent.Body;
            base.Initialize();
        }
コード例 #4
0
ファイル: Demo5.cs プロジェクト: rbrother/seikkailulaakso
        public override void Initialize()
        {
            physicsSimulator = new PhysicsSimulator(new Vector2(0, 0));
            int borderWidth = (int) (ScreenManager.ScreenHeight*.05f);
            _border = new Border(ScreenManager.ScreenWidth, ScreenManager.ScreenHeight, borderWidth,
                                 ScreenManager.ScreenCenter);
            _border.Load(this, physicsSimulator);

            _agent = new Agent(ScreenManager.ScreenCenter);
            _agent.CollisionCategory = CollisionCategory.Cat5;
            _agent.CollidesWith = CollisionCategory.All & ~CollisionCategory.Cat4; //collide with all but Cat4(black)
            _agent.Load(this, physicsSimulator);

            LoadCircles();
            controlledBody = _agent.Body;
            base.Initialize();
        }