public void Update(GameTime gameTime, InputState inputState) { if (inputState.RightMousePressed()) { Point offset = new Point(inputState.LastMousePosition.X - inputState.MousePosition.X, inputState.LastMousePosition.Y - inputState.MousePosition.Y); _Screen.Offset(offset); } if(inputState.MouseScrolledUp() || inputState.KeyDown(Keys.PageUp)) { ZoomIn(inputState.MousePosition); } else if (inputState.MouseScrolledDown() || inputState.KeyDown(Keys.PageDown)) { ZoomOut(); } }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> public void Update(GameTime gameTime, InputState inputState) { Ticks++; if (this.Game.IsActive) { GUI.Update(inputState); UserInterfaceMessage guiMessage; while (GUI.GetMessage(out guiMessage)) { switch (guiMessage) { case UserInterfaceMessage.Play: this.State = GameState.Playing; break; case UserInterfaceMessage.Pause: this.State = GameState.Paused; break; case UserInterfaceMessage.Step: this.State = GameState.Paused; Map.Tick(); Ticks = 0; break; default: string message = "Unrecognized GUI Message '" + guiMessage.ToString() + "'."; throw new InvalidOperationException(message); } } if (inputState.KeyDown(Keys.Space)) { if (this.State == GameState.Paused) { this.State = GameState.Playing; } else { this.State = GameState.Paused; } } if (inputState.KeyDown(Keys.Escape)) { SetupMap(); } Camera.Update(gameTime, inputState); if (!inputState.MouseInputHandled && inputState.LeftMouseUp()) { Point clickedCell = Camera.GetCellCoordinatesOfClick(inputState.MousePosition); Map.FlipCell(clickedCell.X, clickedCell.Y); } } if (this.State == GameState.Playing && Ticks >= TickRate) { Map.Tick(); Ticks = 0; } }