예제 #1
0
        public void Load(GraphicsDevice graphicsDevice, PhysicsSimulator physicsSimulator)
        {
            _platformBrush = new RectangleBrush(_width, _height, _color, _borderColor);
            _platformBrush.Load(graphicsDevice);

            //use the body factory to create the physics body
            _platformBody = BodyFactory.Instance.CreateRectangleBody(physicsSimulator, _width, _height, 1);
            _platformBody.IsStatic = true;
            _platformBody.Position = _position;

            _platformGeom = GeomFactory.Instance.CreateRectangleGeom(physicsSimulator, _platformBody, _width, _height);
            _platformGeom.CollisionGroup = 100;
            _platformGeom.CollisionGroup = _collisionGroup;
            _platformGeom.FrictionCoefficient = 1;
        }
예제 #2
0
        private void LoadObstacles()
        {
            _obstacleBrush = new RectangleBrush(128, 32, Color.White, Color.Black);
            _obstacleBrush.Load(ScreenManager.GraphicsDevice);

            _obstacleBodies = new Body[5];
            _obstacleGeoms = new Geom[5];
            for (int i = 0; i < _obstacleBodies.Length; i++)
            {
                _obstacleBodies[i] = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 32, 1);
                _obstacleBodies[i].IsStatic = true;

                if (i == 0)
                {
                    _obstacleGeoms[i] = GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _obstacleBodies[i], 128,
                                                                                 32);
                    _obstacleGeoms[i].RestitutionCoefficient = .2f;
                    _obstacleGeoms[i].FrictionCoefficient = .2f;
                }
                else
                {
                    _obstacleGeoms[i] = GeomFactory.Instance.CreateGeom(PhysicsSimulator, _obstacleBodies[i],
                                                                        _obstacleGeoms[0]);
                }
            }

            _obstacleBodies[0].Position = ScreenManager.ScreenCenter + new Vector2(-50, -200);
            _obstacleBodies[1].Position = ScreenManager.ScreenCenter + new Vector2(150, -100);
            _obstacleBodies[2].Position = ScreenManager.ScreenCenter + new Vector2(100, 50);
            _obstacleBodies[3].Position = ScreenManager.ScreenCenter + new Vector2(-100, 200);
            _obstacleBodies[4].Position = ScreenManager.ScreenCenter + new Vector2(-170, 0);
        }
예제 #3
0
        public override void LoadContent()
        {
            _circleBrush = new CircleBrush(64, Color.White, Color.Black);
            _circleBrush.Load(ScreenManager.GraphicsDevice);

            _circleBody = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 64, 1);
            _circleBody.Position = new Vector2(725, 384);
            _circleGeom = GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _circleBody, 64, 20);

            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1);
            _rectangleBody.Position = new Vector2(256, 384);
            GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _rectangleBody, 128, 128);

            _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black);
            _rectangleBrush.Load(ScreenManager.GraphicsDevice);

            _p1 = ScreenManager.ScreenCenter;
            _p2 = _circleGeom.Position;

            _lineBrush = new LineBrush(1, Color.Black);
            _lineBrush.Load(ScreenManager.GraphicsDevice);

            _marker = new CircleBrush(3, Color.Red, Color.Red);
            _marker.Load(ScreenManager.GraphicsDevice);

            base.LoadContent();
        }
        private void LoadSliderJointContent(GraphicsDevice graphicsDevice)
        {
            _sliderJointLineBrush = new LineBrush(_sliderJointLineThickness, _sliderJointColor);
            _sliderJointRectangleBrush = new RectangleBrush(10, 10, _sliderJointColor, _sliderJointColor);

            _sliderJointLineBrush.Load(graphicsDevice);
            _sliderJointRectangleBrush.Load(graphicsDevice);
        }
        private void LoadRevoluteJointContent(GraphicsDevice graphicsDevice)
        {
            _revoluteJointLineBrush = new LineBrush(_revoluteJointLineThickness, _revoluteJointColor);
            _revoluteJointRectangleBrush = new RectangleBrush(10, 10, _revoluteJointColor, _revoluteJointColor);

            _revoluteJointLineBrush.Load(graphicsDevice);
            _revoluteJointRectangleBrush.Load(graphicsDevice);
        }
예제 #6
0
        public override void LoadContent()
        {
            //load texture that will visually represent the physics body
            _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black);
            _rectangleBrush.Load(ScreenManager.GraphicsDevice);

            //use the body factory to create the physics body
            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1);
            _rectangleBody.Position = ScreenManager.ScreenCenter;

            base.LoadContent();
        }
예제 #7
0
        public override void LoadContent()
        {
            //We create the brush that will be used to draw the circle
            _circleBrush = new CircleBrush(64, Color.White, Color.Black);
            _circleBrush.Load(ScreenManager.GraphicsDevice);

            //A body is used to simulate forces and impulses
            _circleBody = BodyFactory.Instance.CreateCircleBody(PhysicsSimulator, 64, 1);
            _circleBody.Position = new Vector2(725, 384);

            //A geometry is needed to get collision detection on the body
            GeomFactory.Instance.CreateCircleGeom(PhysicsSimulator, _circleBody, 64, 20);

            _rectangleBody = BodyFactory.Instance.CreateRectangleBody(PhysicsSimulator, 128, 128, 1);
            _rectangleBody.Position = new Vector2(256, 384);
            GeomFactory.Instance.CreateRectangleGeom(PhysicsSimulator, _rectangleBody, 128, 128);

            _rectangleBrush = new RectangleBrush(128, 128, Color.Gold, Color.Black);
            _rectangleBrush.Load(ScreenManager.GraphicsDevice);

            base.LoadContent();
        }