private static bool isShiftHeld() { bool leftShift = RawKeyboardInput.IsHeld(Keys.LeftShift); bool rightShift = RawKeyboardInput.IsHeld(Keys.RightShift); return(leftShift || rightShift); }
protected override void Update(GameTime gameTime) { if (nextWorld != null && World != nextWorld) { swapWorld(); } IsInFocus = IsActive; InputManager.Update(); RawKeyboardInput.Update(); RawGamepadInput.Update(); MouseReader.Update(); Time.Set(gameTime); base.Update(gameTime); Console.Update(); if (!Console.IsDisplaying && !PauseWorld) { UpdateGameplay(); } Renderer.Update(); }
private void handleKeyboardInput() { Keys key = RawKeyboardInput.GetSingleJustPressedKey(); if (key == Keys.None) // if did not press a new key { if (lastKey != Keys.None) // but key was down on previous frame { checkKeyRepeat(); if (isRepeatingKey) { handleContinueRepeatingKey(); } else { handleBeginRepeatingKey(); } } return; } if (isRepeatingKey) { resetKeyRepeat(); } lastKey = key; handleSingleKey(key); }
protected override void Update() { if (RawKeyboardInput.IsPressed(Keys.Space)) { playRandomSong(); } else if (RawKeyboardInput.IsPressed(Keys.R)) { restartSong(); } else if (RawKeyboardInput.IsPressed(Keys.Up)) { playPreviousAlbum(); } else if (RawKeyboardInput.IsPressed(Keys.Down)) { playNextAlbum(); } else if (RawKeyboardInput.IsPressed(Keys.Left)) { playPreviousSong(); } else if (RawKeyboardInput.IsPressed(Keys.Right)) { playNextSong(); } }
protected override void Update() { if (RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift)) { rectRenderer.Image.Color = Color.DodgerBlue; } else { rectRenderer.Image.Color = Color.White; } }
protected override void Update() { if (RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift)) { Object.Stop(); updateBumpControl(); } else { updateSmoothControl(); } }
protected override void Update() { if (RawKeyboardInput.IsPressed(LeftBumpKey)) { current -= RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift) ? bumpPercentage * .5f : bumpPercentage; OnAdjustControl(MathHelper.Lerp(Min, Max, current)); } else if (RawKeyboardInput.IsPressed(RightBumpKey)) { current += RawKeyboardInput.IsHeld(Keys.LeftShift, Keys.RightShift) ? bumpPercentage * .5f : bumpPercentage; OnAdjustControl(MathHelper.Lerp(Min, Max, current)); } }
protected override void Update() { for (int v = 0; v < 8; v++) { if (RawKeyboardInput.IsPressed(numRowKeys[v], numPadKeys[v])) { bool isMuted = enabledVoices[v].DrawEnabled; Music.SetVoiceMute(v, isMuted); enabledVoices[v].DrawEnabled = !isMuted; } } }
protected override void Initialize() { base.Initialize(); MouseReader.Initialize(); RawKeyboardInput.Initialize(); RawGamepadInput.Initialize(); GameSpeed.Reinitialize(); GraphicsDevice.SamplerStates[0] = SamplerState.PointClamp; DebugHelper.Initialize(); MouseVisible = StartMouseVisible; InitializeGame(); }
public override void Update() { base.Update(); if (RawKeyboardInput.IsPressed(Keys.OemTilde)) { IsDisplaying = !IsDisplaying; } if (!IsDisplaying) { return; } handleKeyboardInput(); }
private void checkKeyRepeat() { if (RawKeyboardInput.IsHeld(lastKey)) // if key from last frame is still down on this frame, we're in repeat territory { lastKeyHoldTimeSecs += Time.Seconds; if (!isRepeatingKey) { handleBeginRepeatingKey(); } else { handleContinueRepeatingKey(); } } else // key repeat is over. RESET EVERYTHING! { resetKeyRepeat(); } }
private void updateBumpControl() { if (RawKeyboardInput.IsPressed(Keys.Left, Keys.A)) { Object.LocalPosition = Object.LocalPosition.PlusX(-1); } else if (RawKeyboardInput.IsPressed(Keys.Right, Keys.D)) { Object.LocalPosition = Object.LocalPosition.PlusX(1); } if (RawKeyboardInput.IsPressed(Keys.Up, Keys.W)) { Object.LocalPosition = Object.LocalPosition.PlusY(-1); } else if (RawKeyboardInput.IsPressed(Keys.Down, Keys.S)) { Object.LocalPosition = Object.LocalPosition.PlusY(1); } }
private void updateSmoothControl() { int newX; if (RawKeyboardInput.IsHeld(Keys.Left, Keys.A)) { newX = -1; } else if (RawKeyboardInput.IsHeld(Keys.Right, Keys.D)) { newX = 1; } else { newX = 0; } int newY; if (RawKeyboardInput.IsHeld(Keys.Up, Keys.W)) { newY = -1; } else if (RawKeyboardInput.IsHeld(Keys.Down, Keys.S)) { newY = 1; } else { newY = 0; } if (newX != lastX || newY != lastY) { Object.Velocity = new Vector2(newX * Speed, newY * Speed); } lastX = newX; lastY = newY; }
protected override void Update() { AxisDirections?moveDirection = null; if (RawKeyboardInput.IsPressed(Keys.W) || RawGamepadInput.IsDpadPressed(AxisDirections.Up) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Up)) { moveDirection = AxisDirections.Up; } else if (RawKeyboardInput.IsPressed(Keys.D) || RawGamepadInput.IsDpadPressed(AxisDirections.Right) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Right)) { moveDirection = AxisDirections.Right; } else if (RawKeyboardInput.IsPressed(Keys.S) || RawGamepadInput.IsDpadPressed(AxisDirections.Down) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Down)) { moveDirection = AxisDirections.Down; } else if (RawKeyboardInput.IsPressed(Keys.A) || RawGamepadInput.IsDpadPressed(AxisDirections.Left) || RawGamepadInput.IsLeftJoystickPressed(AxisDirections.Left)) { moveDirection = AxisDirections.Left; } if (moveDirection != null) { Point destination = coords + ((AxisDirections)moveDirection).ToPoint(); if (checkCanMove(destination)) { GameGrid[coords.X, coords.Y] = null; GameGrid[destination.X, destination.Y] = Object; coords = destination; } } Diagonals?diagonalDir = null; if (RawKeyboardInput.IsPressed(Keys.Q)) { diagonalDir = Diagonals.UpLeft; } else if (RawKeyboardInput.IsPressed(Keys.E)) { diagonalDir = Diagonals.UpRight; } else if (RawKeyboardInput.IsPressed(Keys.Z)) { diagonalDir = Diagonals.DownLeft; } else if (RawKeyboardInput.IsPressed(Keys.C)) { diagonalDir = Diagonals.DownRight; } if (diagonalDir != null) { Sfx.PlaySfx("sfx1"); GameObject projectileObj = ProjectileController.BuildObject(PROJ_SPEED, PROJ_SIZE, PROJ_BOUNCES, ((Diagonals)diagonalDir).ToVector2()); projectileObj.LocalPosition = Object.LocalPosition.Plus(tileSize / 2 - 1); Pigeon.World.AddObj(projectileObj); } }