/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { graphics.PreferredBackBufferWidth = 800; graphics.PreferredBackBufferHeight = 600; graphics.SynchronizeWithVerticalRetrace = false; graphics.ApplyChanges(); assets = new Dictionary<string, Texture2D>(); gameObjects = new List<GameObject>(); phySim = new PhysicsSimulator(new Vector2(0, -200)); var ballObject = GameObjectFactory.CreateCircleGameObject(phySim, "ball", 22f, 1); ballObject.Center = new Vector2(250, 400); ballObject.Geom.FrictionCoefficient = 0; FixedAngleJoint asdf = new FixedAngleJoint(ballObject.Body, 0); phySim.Add(asdf); player = ballObject; gameObjects.Add(ballObject); var platformObject = GameObjectFactory.CreateRectangleGameObject(phySim, "platform", 256, 64, 6); platformObject.IsStatic = true; platformObject.Center = new Vector2(250, 300); platformObject.Rotation = MathHelper.ToRadians(-30f); var platformObject2 = GameObjectFactory.CreateRectangleGameObject(phySim, "platform", 256, 64, 6); platformObject2.Center = new Vector2(5, 150); platformObject2.Rotation = MathHelper.ToRadians(90f); platformObject2.Geom.FrictionCoefficient = 10; var floorObject = GameObjectFactory.CreateRectangleGameObject(phySim, "floor", 1024, 12, 1); floorObject.Center = new Vector2(500, 0); floorObject.IsStatic = true; floorObject.Geom.FrictionCoefficient = 1; camera = new Camera2d(new Vector2(0, 0), new Vector2(800, 600), new Vector2(100, 100)); gameObjects.Add(floorObject); gameObjects.Add(platformObject2); gameObjects.Add(platformObject); base.Initialize(); }
public FixedAngleJoint CreateFixedAngleJoint(Body body) { FixedAngleJoint fixedAngleJoint = new FixedAngleJoint(body); return fixedAngleJoint; }