예제 #1
0
        /// <summary>
        /// Called after the application has been initialized.
        /// </summary>
        protected override void OnInitialized()
        {
            SetFileSourceFromManifestIfExists("UltravioletGame.Content.uvarc");

            MouseInputBinding mib = new MouseInputBinding(this.Ultraviolet, MouseButton.Left);
            mouse = mib.Mouse;

            //initialize the firingBullet bool
            firingBullet = false;

            //Setup Box2D world
            worldAABB = new AABB();
            worldAABB.Center.Set(0F, 0F);
            worldAABB.LowerBound.Set(-100F);
            worldAABB.UpperBound.Set(100F);
            physicsWorld = new World(worldAABB, new Vec2(0F, 9.8F), true);

            BodyDef physicsTestDef = new BodyDef();
            physicsTestDef.Position.Set(0F, 0F);

            //physicsTestObject = new GameObject();
            //physicsTestObject.body2D = physicsWorld.CreateBody(physicsTestDef);

            PolygonDef physicsTestShapeDef = new PolygonDef();

            physicsTestShapeDef.SetAsBox(1F, 1F);
            physicsTestShapeDef.Density = 1F;

            //physicsTestObject.body2D.CreateFixture(physicsTestShapeDef);
            //physicsTestObject.body2D.SetMassFromShapes();

            BodyDef groundDef = new BodyDef();
            groundDef.Position.Set(0F, 3F);

            groundTestObject = new GameObject();
            groundTestObject.body2D = physicsWorld.CreateBody(groundDef);

            PolygonDef groundShapeDef = new PolygonDef();

            groundShapeDef.SetAsBox(1F, 1F);
            groundTestObject.body2D.CreateFixture(groundShapeDef);

            base.OnInitialized();
        }
예제 #2
0
 private void MoveGameObject(Vec2 direction, GameObject gameObj)
 {
     gameObj.body2D.ApplyForce(direction, gameObj.position.ToWorldVector());
 }