コード例 #1
0
ファイル: Game1.cs プロジェクト: xesf/Box2DFluid
        protected override void Initialize()
        {
            _world     = new World(new Vector2(0, 9.8f));
            _debugView = new DebugViewXNA(_world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.DefaultShapeColor  = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            base.Initialize();

            _fluidSimulation = new FluidSimulation(_world, _spriteBatch, _debugFont);
            _projection      = Matrix.CreateOrthographic(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1);
            _view            = Matrix.CreateScale(new Vector3(SCALE, -SCALE, 1));

            // Create test geometry
            Body         bottomBody  = BodyFactory.CreateBody(_world, new Vector2(0, 7f));
            PolygonShape bottomShape = new PolygonShape(1f);

            bottomShape.SetAsBox(12f, 1f);
            bottomBody.CreateFixture(bottomShape);

            Body         leftBody  = BodyFactory.CreateBody(_world, new Vector2(-11f, 0f));
            PolygonShape leftShape = new PolygonShape(1f);

            leftShape.SetAsBox(1f, 10f);
            leftBody.CreateFixture(leftShape);

            Body         rightBody  = BodyFactory.CreateBody(_world, new Vector2(11f, 0f));
            PolygonShape rightShape = new PolygonShape(1f);

            rightShape.SetAsBox(1f, 10f);
            rightBody.CreateFixture(rightShape);

            Body         rampBody  = BodyFactory.CreateBody(_world, new Vector2(6f, -2f));
            PolygonShape rampShape = new PolygonShape(1f);

            rampShape.SetAsBox(5.5f, 0.5f);
            rampBody.CreateFixture(rampShape);
            rampBody.Rotation = -0.25f;

            Body        circleBody  = BodyFactory.CreateBody(_world, new Vector2(0, -0.2f));
            CircleShape circleShape = new CircleShape(2f, 1f);

            circleBody.CreateFixture(circleShape);
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: klutch/Box2DFluid
        protected override void Initialize()
        {
            _world = new World(new Vector2(0, 9.8f));
            _debugView = new DebugViewXNA(_world);
            _debugView.AppendFlags(FarseerPhysics.DebugViewFlags.Shape);
            _debugView.DefaultShapeColor = Color.White;
            _debugView.SleepingShapeColor = Color.LightGray;
            _debugView.LoadContent(GraphicsDevice, Content);

            base.Initialize();

            _fluidSimulation = new FluidSimulation(_world, _spriteBatch, _debugFont);
            _projection = Matrix.CreateOrthographic(GraphicsDevice.Viewport.Width, GraphicsDevice.Viewport.Height, 0, 1);
            _view = Matrix.CreateScale(new Vector3(SCALE, -SCALE, 1));

            // Create test geometry
            Body bottomBody = BodyFactory.CreateBody(_world, new Vector2(0, 7f));
            PolygonShape bottomShape = new PolygonShape(1f);
            bottomShape.SetAsBox(12f, 1f);
            bottomBody.CreateFixture(bottomShape);

            Body leftBody = BodyFactory.CreateBody(_world, new Vector2(-11f, 0f));
            PolygonShape leftShape = new PolygonShape(1f);
            leftShape.SetAsBox(1f, 10f);
            leftBody.CreateFixture(leftShape);

            Body rightBody = BodyFactory.CreateBody(_world, new Vector2(11f, 0f));
            PolygonShape rightShape = new PolygonShape(1f);
            rightShape.SetAsBox(1f, 10f);
            rightBody.CreateFixture(rightShape);

            Body rampBody = BodyFactory.CreateBody(_world, new Vector2(6f, -2f));
            PolygonShape rampShape = new PolygonShape(1f);
            rampShape.SetAsBox(5.5f, 0.5f);
            rampBody.CreateFixture(rampShape);
            rampBody.Rotation = -0.25f;

            Body circleBody = BodyFactory.CreateBody(_world, new Vector2(0, -0.2f));
            CircleShape circleShape = new CircleShape(2f, 1f);
            circleBody.CreateFixture(circleShape);
        }