protected override void OnUpdateFrame(FrameEventArgs e) { // called once per frame; app logic var keyboard = OpenTK.Input.Keyboard.GetState(); if (keyboard.IsKeyDown(Key.Plus) || keyboard.IsKeyDown(Key.KeypadPlus)) { game.zoom *= 1.05f; } else if (keyboard.IsKeyDown(Key.Minus) || keyboard.IsKeyDown(Key.KeypadMinus)) { game.zoom /= 1.05f; if (game.zoom < 1) { game.zoom = 1; } } else if (keyboard[Key.Escape]) { this.Exit(); } var mouse = OpenTK.Input.Mouse.GetState(); Point p = CursorPosition.GetCursorPosition(); game.SetMouseState(p.X, p.Y, mouse.LeftButton == ButtonState.Pressed); }
protected override void OnUpdateFrame(FrameEventArgs e) { //UPDATE. called once per frame; app logic var keyboard = OpenTK.Input.Keyboard.GetState(); if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); } var mouse = OpenTK.Input.Mouse.GetState(); Point p = CursorPosition.GetCursorPosition(); //mouse drag function handling, p.X & p.Y are the current mouse positions. game.SetMouseState(p.X, p.Y, mouse.LeftButton == ButtonState.Pressed); //mouse zoom function, work with the mouse.Scroll if (mouse.Wheel - mouseWheelValue >= 1) { mouseWheelValue = mouse.Wheel; if (game.scale < 8) { game.scale++; } } if (mouse.Wheel - mouseWheelValue <= -1) { mouseWheelValue = mouse.Wheel; if (game.scale > 1) { game.scale--; } } }
protected override void OnUpdateFrame(FrameEventArgs e) { // called once per frame; app logic var keyboard = OpenTK.Input.Keyboard.GetState(); if (keyboard[OpenTK.Input.Key.Escape]) { this.Exit(); } var mouse = OpenTK.Input.Mouse.GetState(); Point p = CursorPosition.GetCursorPosition(); game.SetMouseState(p.X, p.Y, mouse.LeftButton == ButtonState.Pressed); }