public ScreenCollisionBorder(float screenWidth, float screenHeight, PhysicsSimulator physicsSimulator )
        {
            LeftBorder = new RectangleRigidBody(borderThickness, screenHeight, 1);
            LeftBorder.Position = new Vector2(-borderThickness/2,screenHeight/2);
            LeftBorder.FrictionCoefficient = .3f;
            LeftBorder.IsStatic = true;

            RightBorder = new RectangleRigidBody(borderThickness, screenHeight, 1);
            RightBorder.Position = new Vector2(screenWidth + borderThickness / 2, screenHeight / 2);
            RightBorder.FrictionCoefficient = .3f;
            RightBorder.IsStatic = true;

            TopBorder = new RectangleRigidBody(screenWidth, borderThickness, 1);
            TopBorder.Position = new Vector2(screenWidth / 2, -borderThickness / 2);
            TopBorder.FrictionCoefficient = .3f;
            TopBorder.IsStatic = true;

            BottomBorder = new RectangleRigidBody(screenWidth, borderThickness, 1);
            BottomBorder.Position = new Vector2(screenWidth / 2, screenHeight + borderThickness / 2);
            BottomBorder.FrictionCoefficient = .3f;
            BottomBorder.IsStatic = true;

            physicsSimulator.Add(LeftBorder);
            physicsSimulator.Add(RightBorder);
            physicsSimulator.Add(TopBorder);
            physicsSimulator.Add(BottomBorder);
        }
示例#2
0
        private List<cRigidBodyGameObject> _rigidBodies; // This will need to be more generic later, when we need non-rectangle objects

        #endregion Fields

        #region Constructors

        public cPhysics()
        {
            _instance = this;

            _gravity = new Vector2(0, 9.81f);

            _physicsSimulator = new PhysicsSimulator(_gravity*18);
            //_physicsSimulator.AllowedPenetrations = 1;
            //_physicsSimulator.BiasFactor = 0.1f;
            _rigidBodies = new List<cRigidBodyGameObject>();
        }