private void HandleMouseInput(InputState input) { if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { Box box = new Box(25, 25, new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y)); box.Load(ScreenManager.GraphicsDevice, PhysicsSimulator); _boxes.Add(box); } }
public override void LoadContent() { _cameraMatrix = Matrix.Identity; _projectionMatrix = Matrix.CreateOrthographicOffCenter(0, ScreenManager.ScreenWidth, ScreenManager.ScreenHeight, 0, -100, 100); _worldMatrix = Matrix.Identity; _waterModel = new WaterModel(); _waterModel.Initialize(PhysicsSimulator, new Vector2(ScreenManager.ScreenHeight * .05f, 500), new Vector2(ScreenManager.ScreenWidth - ((ScreenManager.ScreenHeight * .05f) * 2.0f), ScreenManager.ScreenHeight - 500)); _waterModel.WaveController.Enabled = true; // if false waves will not be created _platform = new Box(300, 20, new Vector2(ScreenManager.ScreenWidth / 2f, 500)); _platform.Load(ScreenManager.GraphicsDevice, PhysicsSimulator); _refTexture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 32, 32, 2, 0, 0, Color.White, Color.Black); _refBody = BodyFactory.Instance.CreateRectangleBody(32, 32, 3f); _refGeom = GeomFactory.Instance.CreateRectangleGeom(_refBody, 32, 32); _refGeom.FrictionCoefficient = .2f; //create the _pyramid near the bottom of the screen. _pyramid = new Pyramid(_refBody, _refGeom, 32f / 3f, 32f / 3f, 32, 32, _pyramidBaseBodyCount, new Vector2(ScreenManager.ScreenCenter.X - _pyramidBaseBodyCount * .5f * (32 + 32 / 3) + 20, ScreenManager.ScreenHeight - 300)); _pyramid.Load(PhysicsSimulator); //Add the geometries to the watermodel's fluiddragcontroller to make them float. _waterModel.FluidDragController.AddGeom(_platform.Geom); foreach (Geom geom in _pyramid.Geoms) { _waterModel.FluidDragController.AddGeom(geom); } // load a font _font = ScreenManager.ContentManager.Load<SpriteFont>("Content/Fonts/detailsfont"); base.LoadContent(); }
public override void LoadContent() { _texture = DrawingHelper.CreateRectangleTexture(ScreenManager.GraphicsDevice, 25, 25, Color.White, Color.Black); //Create 5x13 boxes for (int y = 1; y < 6; y++) { for (int x = 1; x < 14; x++) { Box box = new Box(25, 25, new Vector2(300 + x * 28, 300 + y * 28)); box.Load(ScreenManager.GraphicsDevice, PhysicsSimulator); _boxes.Add(box); } } base.LoadContent(); }