public override void HandleInput(InputState input) { if (firstRun) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); firstRun = false; } if (input.PauseGame) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); } // do some keyboard torque stuff if (input.CurrentKeyboardState.IsKeyDown(Keys.Left)) { _torque = -3500; } else if (input.CurrentKeyboardState.IsKeyDown(Keys.Right)) { _torque = 3500; } else { _torque = 0; _wheel1.ClearTorque(); _wheel2.ClearTorque(); } _wheel1.ApplyAngularImpulse(_torque); _wheel2.ApplyAngularImpulse(_torque); base.HandleInput(input); }
public override void HandleInput(InputState input) { if (firstRun) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); firstRun = false; } if (input.PauseGame) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); } base.HandleInput(input); }
public override void HandleInput(InputState input) { if (firstRun) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); firstRun = false; } if (input.PauseGame) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); } if (input.CurrentGamePadState.IsConnected) { HandleGamePadInput(input); } else { HandleKeyboardInput(input); } base.HandleInput(input); }
public override void HandleInput(InputState input) { Random rand = new Random(); if (firstRun) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); firstRun = false; } if (input.PauseGame) { ScreenManager.AddScreen(new PauseScreen(GetTitle(), GetDetails())); } if (input.CurrentMouseState.RightButton == ButtonState.Pressed && broke && count > 10) { broke = false; weldJoint = new WeldJoint(bodyA, bodyB, new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y)); weldJoint.Breakpoint = 5.0f; weldJoint.Broke += weldJoint_Broke; PhysicsSimulator.Add(weldJoint); count = 0; } else if (input.CurrentMouseState.MiddleButton == ButtonState.Pressed && input.LastMouseState.MiddleButton == ButtonState.Released && count > 10) { table.Add(new Table(new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y), rand.Next(100, 300), rand.Next(20, 50))); table[table.Count - 1].Load(PhysicsSimulator, ScreenManager.GraphicsDevice); count = 0; } count++; base.HandleInput(input); }
private void HandleMouseInput(InputState input) { _p2 = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); }
private void HandleGamePadInput(InputState input) { _p1 = new Vector2(input.CurrentGamePadState.ThumbSticks.Left.X, input.CurrentGamePadState.ThumbSticks.Left.Y); _p2 = new Vector2(input.CurrentGamePadState.ThumbSticks.Right.X, input.CurrentGamePadState.ThumbSticks.Right.Y); }
/// <summary> /// Responds to user input, changing the selected entry and accepting /// or canceling the menu. /// </summary> public override void HandleInput(InputState input) { // Move to the previous menu entry? if (input.MenuUp) { _selectedEntry--; if (_selectedEntry < 0) _selectedEntry = _menuEntries.Count - 1; } // Move to the next menu entry? if (input.MenuDown) { _selectedEntry++; if (_selectedEntry >= _menuEntries.Count) _selectedEntry = 0; } // Accept or cancel the menu? if (input.MenuSelect) { OnSelectEntry(_selectedEntry); } }
private void HandleKeyboardInput(InputState input) { const float forceAmount = 800; Vector2 force = Vector2.Zero; force.Y = -force.Y; if (input.CurrentKeyboardState.IsKeyDown(Keys.A)) { force += new Vector2(-forceAmount, 0); } if (input.CurrentKeyboardState.IsKeyDown(Keys.S)) { force += new Vector2(0, forceAmount); } if (input.CurrentKeyboardState.IsKeyDown(Keys.D)) { force += new Vector2(forceAmount, 0); } if (input.CurrentKeyboardState.IsKeyDown(Keys.W)) { force += new Vector2(0, -forceAmount); } _agent.Body.ApplyForce(force); const float torqueAmount = 8000; float torque = 0; if (input.CurrentKeyboardState.IsKeyDown(Keys.Left)) { torque -= torqueAmount; } if (input.CurrentKeyboardState.IsKeyDown(Keys.Right)) { torque += torqueAmount; } _agent.Body.ApplyTorque(torque); }
private void HandleMouseInput(InputState input) { if (input.LastMouseState.RightButton == ButtonState.Released && input.CurrentMouseState.RightButton == ButtonState.Pressed) { Vector2 point = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); Grenade grenade = new Grenade(point, PhysicsSimulator); grenade.Load(_grenadeTexture); grenade.OnTimeout += Grenade_OnTimeout; _grenades.Add(grenade); } if (input.CurrentMouseState.LeftButton == ButtonState.Pressed) { Vector2 point = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); _hairDryer.Position = point; } }
private void HandleKeyboardInput(InputState input) { if (input.LastKeyboardState.IsKeyUp(Keys.R) && input.CurrentKeyboardState.IsKeyDown(Keys.R)) { ExitScreen(); ScreenManager.AddScreen(new Demo1Screen(!_usePool)); } }
private void HandleKeyboardInput(InputState input) { if (count > 5) // this is used to slow down the input a little { if (input.CurrentKeyboardState.IsKeyDown(Keys.Z)) { _waterModel.WaveController.WaveGeneratorMax -= 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.X)) { _waterModel.WaveController.WaveGeneratorMax += 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.C)) { _waterModel.WaveController.WaveGeneratorMin -= 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.V)) { _waterModel.WaveController.WaveGeneratorMin += 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.B)) { _waterModel.WaveController.WaveGeneratorStep -= 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.N)) { _waterModel.WaveController.WaveGeneratorStep += 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.A)) { _waterModel.FluidDragController.Density -= 0.0001f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.S)) { _waterModel.FluidDragController.Density += 0.0001f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.D)) { _waterModel.FluidDragController.LinearDragCoefficient -= 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.F)) { _waterModel.FluidDragController.LinearDragCoefficient += 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.G)) { _waterModel.FluidDragController.RotationalDragCoefficient -= 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.H)) { _waterModel.FluidDragController.RotationalDragCoefficient += 0.1f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.Q)) { _waterModel.WaveController.DampingCoefficient -= 0.001f; } if (input.CurrentKeyboardState.IsKeyDown(Keys.E)) { _waterModel.WaveController.DampingCoefficient += 0.001f; } count = 0; } count++; }
private void HandleGamePadInput(InputState input) { // TODO - add simple property control through gamepad }
public override void HandleInput(InputState input) { if (input.CurrentGamePadState.IsConnected) { HandleGamePadInput(input); } else { HandleKeyboardInput(input); } base.HandleInput(input); }
private void HandleMouseInput(InputState input) { if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && input.LastMouseState.LeftButton == ButtonState.Released) { foreach (Geom g in PhysicsSimulator.GeomList) { if (g.Collide(new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y))) { _selectedGeom = g; break; } } } if (input.CurrentMouseState.LeftButton == ButtonState.Released && input.LastMouseState.LeftButton == ButtonState.Pressed) { _selectedGeom = null; } MouseMove(input.LastMouseState, input.CurrentMouseState); }
private void HandKeyboardInput(InputState input) { if (input.OneOfKeysPressed(Keys.Q, Keys.W, Keys.E, Keys.A, Keys.S, Keys.D)) if (_leftGeom == null || _rightGeom == null) { // Add Circles if (input.IsNewKeyPress(Keys.Q)) { AddCircle(50, 8); } // Add Circles if (input.IsNewKeyPress(Keys.W)) { AddCircle(50, 16); } // Add Circles if (input.IsNewKeyPress(Keys.E)) { AddCircle(50, 32); } // Add Rectangle if (input.IsNewKeyPress(Keys.A)) { AddRectangle(100, 100); } // Add Rectangle if (input.IsNewKeyPress(Keys.S)) { AddRectangle(100, 50); } // Add Rectangle if (input.IsNewKeyPress(Keys.D)) { AddRectangle(50, 100); } } else { WriteMessage("Only 2 polygons allowed at a time."); } // Perform a Union if (input.IsNewKeyPress(Keys.Space)) { if (_leftGeom != null && _rightGeom != null) { DoUnion(); } } // Perform a Subtraction if (input.IsNewKeyPress(Keys.Back)) { if (_leftGeom != null && _rightGeom != null) { DoSubtract(); } } // Simplify if (input.IsNewKeyPress(Keys.Tab)) { if (_leftGeom != null && _rightGeom == null) { Vertices simple = new Vertices(_leftGeom.WorldVertices); simple = Vertices.Simplify(simple); SetProduct(simple); } } // Add to Simulation if (input.IsNewKeyPress(Keys.Enter)) { if (_leftGeom != null) { Body body = BodyFactory.Instance.CreatePolygonBody(_leftGeom.LocalVertices, 1.0f); body.Position = _leftGeom.Position; Geom geom = GeomFactory.Instance.CreatePolygonGeom(body, _leftGeom.LocalVertices, 0); PhysicsSimulator.Add(body); PhysicsSimulator.Add(geom); _simulatedPolyBrushes.Add(new PolygonBrush(_leftGeom.LocalVertices, Color.Red, Color.DarkRed, 1.5f, 0.2f)); _simulatedPolyBrushes[_simulatedPolyBrushes.Count - 1].Load(ScreenManager.GraphicsDevice); _simulatedPolyBodies.Add(body); } } }
public override void HandleInput(InputState input) { if (input.CurrentKeyboardState.IsKeyDown(Keys.Escape)) ScreenManager.Game.Exit(); base.HandleInput(input); }
private void HandleGamePadInput(InputState input) { Vector2 force = 800 * input.CurrentGamePadState.ThumbSticks.Left; force.Y = -force.Y; _agent.Body.ApplyForce(force); float rotation = -8000 * input.CurrentGamePadState.Triggers.Left; _agent.Body.ApplyTorque(rotation); rotation = 8000 * input.CurrentGamePadState.Triggers.Right; _agent.Body.ApplyTorque(rotation); }
/// <summary> /// Allows the screen to handle user input. Unlike Update, this method /// is only called when the screen is active, and not when some other /// screen has taken the focus. /// </summary> public virtual void HandleInput(InputState input) { //Xbox if (input.LastGamePadState.Buttons.Y != ButtonState.Pressed && input.CurrentGamePadState.Buttons.Y == ButtonState.Pressed) { DebugViewEnabled = !DebugViewEnabled; PhysicsSimulator.EnableDiagnostics = DebugViewEnabled; } //Windows if (!input.LastKeyboardState.IsKeyDown(Keys.F1) && input.CurrentKeyboardState.IsKeyDown(Keys.F1)) { DebugViewEnabled = !DebugViewEnabled; PhysicsSimulator.EnableDiagnostics = DebugViewEnabled; } #if !XBOX HandleMouseInput(input); #endif }
private void HandleMouseInput(InputState input) { Vector2 point = new Vector2(input.CurrentMouseState.X, input.CurrentMouseState.Y); if (input.LastMouseState.LeftButton == ButtonState.Released && input.CurrentMouseState.LeftButton == ButtonState.Pressed) { //create mouse spring _pickedGeom = PhysicsSimulator.Collide(point); if (_pickedGeom != null) { _mousePickSpring = SpringFactory.Instance.CreateFixedLinearSpring(PhysicsSimulator, _pickedGeom.Body, _pickedGeom.Body. GetLocalPosition(point), point, 100, 50); } } else if (input.LastMouseState.LeftButton == ButtonState.Pressed && input.CurrentMouseState.LeftButton == ButtonState.Released) { //destroy mouse spring if (_mousePickSpring != null && _mousePickSpring.IsDisposed == false) { _mousePickSpring.Dispose(); _mousePickSpring = null; } } //move anchor point if (input.CurrentMouseState.LeftButton == ButtonState.Pressed && _mousePickSpring != null) { _mousePickSpring.WorldAttachPoint = point; } }
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); } }