private void UpdateUniforms(float dt) { Date = new Vector4(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, (float)DateTime.Now.TimeOfDay.TotalSeconds); Mouse = new Vector4(_mouse.GetState().Position.X, _mouse.GetState().Position.Y, (_mouse.GetState().LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) ? 1 : 0, (_mouse.GetState().RightButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) ? 1 : 0); TimeDelta = dt; Time += dt; Resolution = new Vector3(GraphicsDevice.PresentationParameters.Bounds.Size.ToVector2(), 1.0f); if (Channel0 != null) { Channel0.Time += dt; } if (Channel1 != null) { Channel1.Time += dt; } if (Channel2 != null) { Channel2.Time += dt; } if (Channel3 != null) { Channel3.Time += dt; } }
/// <summary> /// The update method that is called to update your game logic. /// </summary> /// <param name="gameTime"></param> protected override void Update(GameTime gameTime) { base.Update(gameTime); var mouseState = mouse.GetState(); if (mouseState.MiddleButton == ButtonState.Released) { middleIsRecord = false; } middlePressed = mouseState.MiddleButton == ButtonState.Pressed; MoveCamera(); }
protected override void Update(GameTime gameTime) { _mouseState = _mouse.GetState(); _keyboardState = _keyboard.GetState(); base.Update(gameTime); }
protected override void Update(GameTime time) { if (_first) { // WPF window is not yet loaded when initialize is called, thus SetCursor does not work there, instead call it in the first update _mouse.SetCursor(GraphicsDevice.Viewport.Width / 2, GraphicsDevice.Viewport.Height / 2); _first = false; } // every update we can now query the keyboard & mouse for our WpfGame var mouseState = _mouse.GetState(); if (mouseState.X == 0 && mouseState.Y == 0) { // WPF returns empty mouseposition at startup, until window is at least once rendered. only then will it return proper mouse positions // so we deferr updating until we get a valid mousestate return; } var keyboardState = _keyboard.GetState(); if (!IsActive()) { return; } if (keyboardState.IsKeyDown(Keys.Escape)) { Environment.Exit(0); } _terrainScene.Update(time, mouseState, keyboardState, (x, y) => _mouse.SetCursor(x, y)); }
protected override void Draw(GameTime time) { var mousePosition = _mouse.GetState(); var defaultRenderTarget = (RenderTarget2D)GraphicsDevice.GetRenderTargets()[0].RenderTarget; // Draws everything normal GraphicsDevice.SetRenderTarget(_baseSceneRenderTarget); GraphicsDevice.Clear(Color.Black); _spriteBatch.Begin(blendState: BlendState.NonPremultiplied); for (int col = 0; col < GraphicsDevice.Viewport.Width; col += _cell.Width) { for (int row = 0; row < GraphicsDevice.Viewport.Height; row += _cell.Height) { _spriteBatch.Draw(_cell, new Vector2(col, row), Color.White); } } _spriteBatch.End(); // Draws the specular map GraphicsDevice.SetRenderTarget(_specularMapRenderTarget); GraphicsDevice.Clear(Color.Black); _spriteBatch.Begin(); for (int col = 0; col < GraphicsDevice.Viewport.Width; col += _cell.Width) { for (int row = 0; row < GraphicsDevice.Viewport.Height; row += _cell.Height) { _spriteBatch.Draw(_cellSpecularMap, new Vector2(col, row), Color.White); } } _spriteBatch.End(); // Draws the lightmask for the specular GraphicsDevice.SetRenderTarget(_specularMapLightMaskRenderTarget); GraphicsDevice.Clear(Color.Black); _spriteBatch.Begin(blendState: BlendState.NonPremultiplied); _spriteBatch.Draw( texture: _lightTexture, position: new Vector2(mousePosition.X, mousePosition.Y), color: Color.White, origin: new Vector2(_lightTexture.Width / 2, _lightTexture.Height / 2), scale: new Vector2(2f)); _spriteBatch.End(); // Applies the lightmask in specular GraphicsDevice.SetRenderTarget(_lightsRenderTarget); GraphicsDevice.Clear(Color.Black); _specularMapShader.Parameters["SpecularTexture"].SetValue((Texture2D)_specularMapLightMaskRenderTarget); _specularMapShader.CurrentTechnique.Passes[0].Apply(); _spriteBatch.Begin(effect: _specularMapShader); _spriteBatch.Draw(_specularMapRenderTarget, Vector2.Zero, Color.White); _spriteBatch.End(); // Compose postprocessed image GraphicsDevice.SetRenderTarget(defaultRenderTarget); GraphicsDevice.Clear(Color.Black); _spriteBatch.Begin(blendState: BlendState.Additive); _spriteBatch.Draw((Texture2D)_baseSceneRenderTarget, Vector2.Zero, Color.White); _spriteBatch.Draw((Texture2D)_lightsRenderTarget, Vector2.Zero, Color.White); _spriteBatch.End(); }
protected override void Update(GameTime time) { // every update we can now query the keyboard & mouse for our WpfGame var mouseState = mouse.GetState(); var keyboardState = keyboard.GetState(); particleSystem.Update(time); }
public void Update() { _lastFrameKBState = _currentKBState; _lastMouseState = _currentMouseState; _currentKBState = _keyboard.GetState(); _currentMouseState = _mouse.GetState(); }
public static void Update() { lastKeys = keys; lastMouse = mouse; keys = wpfKey.GetState(); mouse = wpfMouse.GetState(); }
public void Update(WpfKeyboard keyboard, WpfMouse mouse) { PreviousKeyboardState = CurrentKeyboardState; CurrentKeyboardState = keyboard.GetState(); KeyboardStateExtended = new KeyboardStateExtended(CurrentKeyboardState, PreviousKeyboardState); PreviousMouseState = CurrentMouseState; CurrentMouseState = mouse.GetState(); MouseStateExtended = new MouseStateExtended(CurrentMouseState, PreviousMouseState); }
protected override void Update(GameTime gameTime) { _map.ViewBounds = GraphicsDevice.Viewport.Bounds.ToMapRectangle(); SteuerSoft.Maps.Controls.MonoGame.Material.InputArgs args = new InputArgs(); args.MouseState = _mouse.GetState(); args.KeyboardState = _keyboard.GetState(); _map.Update(gameTime, args); base.Update(gameTime); }
public override void Update(GameTime t) { var currentState = _wpfMouse.GetState(); _lastMousesState = _currentMouseState; _currentMouseState = currentState; if (_lastMousesState == null) { _lastMousesState = currentState; } }
public void Update() { var mouseState = _mouse.GetState(); if (mouseState.LeftButton != _previousMouseState.LeftButton) { if (mouseState.LeftButton == ButtonState.Pressed) { LeftButtonDown?.Invoke(this, new MouseEventArgs(ref mouseState)); } else { LeftButtonUp?.Invoke(this, new MouseEventArgs(ref mouseState)); } } if (mouseState.MiddleButton != _previousMouseState.MiddleButton) { if (mouseState.MiddleButton == ButtonState.Pressed) { MiddleButtonDown?.Invoke(this, new MouseEventArgs(ref mouseState)); } else { MiddleButtonUp?.Invoke(this, new MouseEventArgs(ref mouseState)); } } if (mouseState.RightButton != _previousMouseState.RightButton) { if (mouseState.RightButton == ButtonState.Pressed) { RightButtonDown?.Invoke(this, new MouseEventArgs(ref mouseState)); } else { RightButtonUp?.Invoke(this, new MouseEventArgs(ref mouseState)); } } if (mouseState.Position != _previousMouseState.Position) { MouseMove?.Invoke(this, new MouseMoveEventArgs(mouseState, _previousMouseState.Position)); } if (mouseState.ScrollWheelValue != _previousMouseState.ScrollWheelValue) { MouseWheel?.Invoke(this, new MouseWheelEventArgs(mouseState, mouseState.ScrollWheelValue - _previousMouseState.ScrollWheelValue)); } _previousMouseState = mouseState; }
protected override void Update(GameTime gameTime) { // every update we can now query the keyboard & mouse for our WpfGame var mouseState = mouse.GetState(); var keyboardState = keyboard.GetState(); if (Playing) { SpriteEdited.Update((float)gameTime.ElapsedGameTime.TotalSeconds); } base.Update(gameTime); }
protected override void Update(GameTime time) { // every update we can now query the keyboard & mouse for our WpfGame _mouseState = _mouse.GetState(); _keyboardState = _keyboard.GetState(); if (KeyPressed(Keys.Q)) { //_renderManager.RenderBoxes(); GameManager.GetInstance().GetRenderManager().RenderBoxes(); } //_renderManager.Update(time); GameManager.GetInstance().Update(time); _previousKeyboardState = _keyboardState; _previousMouseState = _mouseState; }
public override void Update(GameTime gameTime) { _input.PreviousKeyboardState = _input.CurrentKeyboardState; _input.PreviousMouseState = _input.CurrentMouseState; _input.CurrentKeyboardState = _keyboard.GetState(); _input.CurrentMouseState = _mouse.GetState(); ViewModel?.LoadContent(Game.Content); ViewModel?.Update(gameTime, _input); if (_input.IsMousePressed(MouseButton.Left) || _input.IsMouseHeld(MouseButton.Left)) { ViewModel?.DrawPrimaryTile(); } if (_input.IsMousePressed(MouseButton.Right) || _input.IsMouseHeld(MouseButton.Right)) { ViewModel?.DrawSecondaryTile(); } base.Update(gameTime); }
protected override void Update(GameTime time) { _mouseState = _mouse.GetState(); _keyboardState = _keyboard.GetState(); if (KeyPressed(Keys.F1)) { FocusOnMouseOver = !FocusOnMouseOver; } if (KeyPressed(Keys.F2)) { _mouse.CaptureMouseWithin = !_mouse.CaptureMouseWithin; } if (KeyPressed(Keys.Delete)) { // clear message EnteredMessage = ""; } else { var sb = new StringBuilder(); for (int i = (int)Keys.A; i <= (int)Keys.Z; i++) { if (KeyPressed((Keys)i)) { // key pressed, add key to queue sb.Append(((char)i)); } } if (KeyPressed(Keys.Space)) { sb.Append(' '); } // concat to message EnteredMessage += sb.ToString().ToLower(); } _previousKeyboardState = _keyboardState; base.Update(time); }
protected override void Update(GameTime gameTime) { var previous = _mouseState; _mouseState = _mouse.GetState(); _keyboardState = _keyboard.GetState(); if (_mouseState.LeftButton == ButtonState.Pressed && previous.LeftButton == ButtonState.Released) { // toggle between 1 and the system value if ((_graphicsDeviceService.DpiScalingFactor - 1) <= 0.0001f) { _graphicsDeviceService.DpiScalingFactor = _graphicsDeviceService.SystemDpiScalingFactor; } else { _graphicsDeviceService.DpiScalingFactor = 1; } } base.Update(gameTime); }
protected override void Update(GameTime gameTime) { var mouse = _mouse.GetState(); _lightPosition = new Vector3(mouse.X, mouse.Y, _lightDirectionZ); }
public void Update(WpfMouse mouse) { PreviousMouseState = CurrentMouseState; CurrentMouseState = mouse.GetState(); MouseStateExtended = new MouseStateExtended(CurrentMouseState, PreviousMouseState); }
protected override void Update(GameTime time) { // every update we can now query the keyboard & mouse for our WpfGame var mouseState = _mouse.GetState(); var keyboardState = _keyboard.GetState(); }
public void Update(GameTime gameTime) { if (Mouse == null) { return; } var mouseState = Mouse.GetState(); var keyboardState = Keyboard.GetState(); if (!Game.IsActive) { PrevMouseState = mouseState; return; } if (keyboardState.IsKeyDown(Keys.W)) { Position += Dir * Speed; } if (keyboardState.IsKeyDown(Keys.S)) { Position -= Dir * Speed; } if (keyboardState.IsKeyDown(Keys.A)) { Position += Vector3.Cross(Up, Dir) * Speed; } if (keyboardState.IsKeyDown(Keys.D)) { Position -= Vector3.Cross(Up, Dir) * Speed; } if (keyboardState.IsKeyDown(Keys.Space)) { Position += Up * Speed; } // camera speed control if (mouseState.ScrollWheelValue != PrevScrollWheelValue) { var diff = mouseState.ScrollWheelValue - PrevScrollWheelValue; if (diff >= 0) { Speed *= SpeedMod; } else { Speed /= SpeedMod; } PrevScrollWheelValue = mouseState.ScrollWheelValue; } if (mouseState.RightButton == ButtonState.Pressed) { if (PrevMouseState.RightButton == ButtonState.Pressed) { // yaw / x-rotation Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Up, -MathHelper.PiOver4 / 160 * (mouseState.X - centerX))); // pitch / y-rotation Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Vector3.Cross(Up, Dir), MathHelper.PiOver4 / 160 * (mouseState.Y - centerY))); } else { System.Windows.Input.Mouse.OverrideCursor = Cursors.None; } // there is a delay here, so Mouse.GetState() won't be immediately affected Mouse.SetCursor(centerX, centerY); } else if (PrevMouseState.RightButton == ButtonState.Pressed) { System.Windows.Input.Mouse.OverrideCursor = Cursors.Arrow; } PrevMouseState = mouseState; Dir.Normalize(); CreateLookAt(); //Console.WriteLine("Camera pos: " + GameView.Instance.Render.Camera.Position); //Console.WriteLine("Camera dir: " + GameView.Instance.Render.Camera.Dir); }
public MouseState GetState() { return(WpfMouse == null?Microsoft.Xna.Framework.Input.Mouse.GetState() : WpfMouse.GetState()); }
protected override void Update(GameTime time) { var keyboardState = _keyboard.GetState(); int velocity; velocity = keyboardState.IsKeyDown(Keys.LeftShift) ? 10 : 1; if (keyboardState.IsKeyDown(Keys.W)) { _y -= velocity; } if (keyboardState.IsKeyDown(Keys.S)) { _y += velocity; } if (keyboardState.IsKeyDown(Keys.A)) { _x -= velocity; } if (keyboardState.IsKeyDown(Keys.D)) { _x += velocity; } //SCALE = 1 + / 10000.0f; var diff = _mouse.GetState().ScrollWheelValue - _prevScrlVal; if (diff > 0) { SCALE += SCALE * 0.5f; } else if (diff < 0) { SCALE -= SCALE * 0.25f; } _prevScrlVal = _mouse.GetState().ScrollWheelValue; DebugInfo.DebugMessage += $"Spawners: {_spawners.Count}\n"; int updateVal = (int)MainWindow.Sliders["UpdatePerFrame"].Value; if (keyboardState.IsKeyDown(Keys.Space)) { return; } if (updateVal <= 0) { if (_counter == 0) { for (int j = _spawners.Count - 1; j >= 0; j--) { if (_spawners[j].IsDeleted) { _spawners.RemoveAt(j); } else { _spawners[j].Update(); } } } _counter = (_counter + 1) % (-updateVal + 2); } else { for (int i = 0; i < updateVal; i++) { for (int j = _spawners.Count - 1; j >= 0; j--) { if (_spawners[j].IsDeleted) { _spawners.RemoveAt(j); } else { _spawners[j].Update(); } } } } base.Update(time); }
public void Update(GameTime gameTime) { if (MouseState == null) { return; } var mouseState = MouseState.GetState(); var keyboardState = KeyboardState.GetState(); if (!Game.IsActive) { PrevMouseState = mouseState; return; } if (keyboardState.IsKeyDown(Keys.W)) { Position += Dir * Speed; } if (keyboardState.IsKeyDown(Keys.S)) { Position -= Dir * Speed; } if (keyboardState.IsKeyDown(Keys.A)) { Position += Vector3.Cross(Up, Dir) * Speed; } if (keyboardState.IsKeyDown(Keys.D)) { Position -= Vector3.Cross(Up, Dir) * Speed; } if (keyboardState.IsKeyDown(Keys.Space)) { Position += Up * Speed; } // camera speed control /*if (mouseState.ScrollWheelValue != PrevScrollWheelValue) * { * var diff = mouseState.ScrollWheelValue - PrevScrollWheelValue; * if (diff >= 0) * Speed *= SpeedMod; * else * Speed /= SpeedMod; * * PrevScrollWheelValue = mouseState.ScrollWheelValue; * } * * // yaw / x-rotation * Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Up, * -MathHelper.PiOver4 / 160 * (mouseState.X - PrevMouseState.X))); * * // pitch / y-rotation * Dir = Vector3.Transform(Dir, Matrix.CreateFromAxisAngle(Vector3.Cross(Up, Dir), * MathHelper.PiOver4 / 160 * (mouseState.Y - PrevMouseState.Y))); * * Dir.Normalize();*/ //SetMouse(); CreateLookAt(); //Console.WriteLine("Camera pos: " + ParticleViewer.Instance.Render.Camera.Position); //Console.WriteLine("Camera dir: " + ParticleViewer.Instance.Render.Camera.Dir); }
protected override void Update(GameTime gameTime) { base.Update(gameTime); _mouseState = _mouse.GetState(); }