public void registerPhysicsGameObject(PhysicsGameObject pgo) { physicsObjects.AddLast(pgo); geomLookup[pgo.boxGeom] = pgo; geomSndLookup[pgo.boxGeom] = 0; IDLookup[pgo.boxGeom] = pgo.ID; }
protected override void Initialize() { base.Initialize(); IsFixedTimeStep = true; TargetElapsedTime = new TimeSpan(0, 0, 0, 0, 10); Matrix viewMatrix; Matrix projectionMatrix; viewMatrix = Matrix.CreateLookAt( new Vector3(0.0f, 0.0f, 1.0f), Vector3.Zero, Vector3.Up ); projectionMatrix = Matrix.CreateOrthographicOffCenter( 0, (float)GraphicsDevice.Viewport.Width, (float)GraphicsDevice.Viewport.Height, 0, 1.0f, 1000.0f); basicEffect = new BasicEffect(GraphicsDevice, null); basicEffect.VertexColorEnabled = true; basicEffect.View = viewMatrix; basicEffect.Projection = projectionMatrix; GraphicsDevice.RenderState.PointSize = 10; //currentRound.setUpKeyboardMap(); //Menu Objects for (int i = 0; i < 6; i = i + 2) { menuObjects[i / 2] = new PhysicsGameObject(applicationPhysicsSimHach, 75, 75, false); menuObjects[i / 2].getTextureSet("Default").addTexture(textureStore.menuTextures[i]); menuObjects[i / 2].getTextureSet("Default").addTexture(textureStore.menuTextures[i + 1]); menuObjects[i / 2].boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), (i / 2) * 200 + 200); applicationPhysicsSimHach.Remove(menuObjects[i / 2].boxGeom); } tutorial = new PhysicsGameObject(applicationPhysicsSimHach, 800, 400, false); tutorialOverlay = new PhysicsGameObject(applicationPhysicsSimHach, 800, 400, false); foreach (Texture2D tex in textureStore.keyTextures) { tutorial.boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), 200 + 200); tutorial.getTextureSet("Default").addTexture(tex); } tutorialOverlay.boxBody.Position = new Vector2(graphics.PreferredBackBufferWidth / 2 - (menuObjects[0].getWidth() / 2), 200 + 200); tutorialOverlay.getTextureSet("Default").addTexture(Content.Load <Texture2D>("Sprites/keyboard/keyboard_lock")); }
public RoundSpecific(Game1 parent) { _parent = parent; physicsController = new PhysicsController(); //p1.cubeSet = new CubeSet(physicsController, parent.textureStore, new Vector2(250, 750/2), 1, parent.sounds); p1.cubeSet = new CubeSet(physicsController, parent.textureStore, new Vector2(250, 750 / 2), 1, this); //p2.cubeSet = new CubeSet(physicsController, parent.textureStore, new Vector2(1024 - 250, 750 / 2), 2, parent.sounds); p2.cubeSet = new CubeSet(physicsController, parent.textureStore, new Vector2(1024 - 250, 750 / 2), 2, this); int cubewidth = 1024; int cubeheight = 768; int cubeborder = 100; floors[0] = new PhysicsGameObject(physicsController.physicsSimulator, cubewidth, cubeborder, true); floors[0].getTextureSet("Default").addTexture(parent.backgroundTexture); floors[0].boxBody.Position = new Vector2(floors[0].boxBody.Position.X + cubewidth / 2, -cubeborder / 2); floors[1] = new PhysicsGameObject(physicsController.physicsSimulator, cubewidth, cubeborder, true); floors[1].getTextureSet("Default").addTexture(parent.backgroundTexture); floors[1].boxBody.Position = new Vector2(floors[1].boxBody.Position.X + cubewidth / 2, cubeheight + cubeborder / 2); floors[2] = new PhysicsGameObject(physicsController.physicsSimulator, cubeborder, cubeheight, true); floors[2].getTextureSet("Default").addTexture(parent.backgroundTexture); floors[2].boxBody.Position = new Vector2(-cubeborder / 2, floors[2].boxBody.Position.Y + cubeheight / 2); floors[3] = new PhysicsGameObject(physicsController.physicsSimulator, cubeborder, cubeheight, true); floors[3].getTextureSet("Default").addTexture(parent.backgroundTexture); floors[3].boxBody.Position = new Vector2(cubewidth + cubeborder / 2, floors[3].boxBody.Position.Y + cubeheight / 2); physicsController.registerPhysicsGameObject(floors[0]); physicsController.registerPhysicsGameObject(floors[1]); physicsController.registerPhysicsGameObject(floors[2]); physicsController.registerPhysicsGameObject(floors[3]); physicsController.geomLookup[floors[0].boxGeom] = floors[0]; physicsController.geomLookup[floors[1].boxGeom] = floors[1]; physicsController.geomLookup[floors[2].boxGeom] = floors[2]; physicsController.geomLookup[floors[3].boxGeom] = floors[3]; floors[0].boxGeom.OnCollision += OnCollision; floors[1].boxGeom.OnCollision += OnCollision; floors[2].boxGeom.OnCollision += OnCollision; floors[3].boxGeom.OnCollision += OnCollision; }
public void deregisterPhysicsGameObject(PhysicsGameObject pgo) { physicsObjects.Remove(pgo); }