public void Update(Player player) { // Save previous keyboard/gamepad states previousKeyboardState = currentKeyboardState; previousGamepadState = currentGamepadState; // Read current keyboard/gamepad currentKeyboardState = Keyboard.GetState(); currentGamepadState = GamePad.GetState(PlayerIndex.One); // Movement (iso & 8dir) //if (currentKeyboardState.IsKeyDown(Keys.Left) || currentGamepadState.ThumbSticks.Left.X < 0) // player.Move("left"); //else if (currentKeyboardState.IsKeyDown(Keys.Right) || currentGamepadState.ThumbSticks.Left.X > 0) // player.Move("right"); //if (currentKeyboardState.IsKeyDown(Keys.Up) || currentGamepadState.ThumbSticks.Left.Y < 0) // player.Move("up"); //else if (currentKeyboardState.IsKeyDown(Keys.Down) || currentGamepadState.ThumbSticks.Left.Y > 0) // player.Move("down"); // Bools for simpler looking conditions bool left = currentKeyboardState.IsKeyDown(Keys.Left) || currentGamepadState.ThumbSticks.Left.X < 0; bool right = currentKeyboardState.IsKeyDown(Keys.Right) || currentGamepadState.ThumbSticks.Left.X > 0; bool up = currentKeyboardState.IsKeyDown(Keys.Up) || currentGamepadState.ThumbSticks.Left.Y < 0; bool down = currentKeyboardState.IsKeyDown(Keys.Down) || currentGamepadState.ThumbSticks.Left.Y > 0; // Movement Combination if (left && !up && !down) player.Move("left"); else if (right && !up && !down) player.Move("right"); else if (up && !left && !right) player.Move("up"); else if (down && !left && !right) player.Move("down"); else if (up && left) player.Move("upleft"); else if (up && right) player.Move("upright"); else if (down && left) player.Move("downleft"); else if (down && right) player.Move("downright"); // Dash if (currentKeyboardState.IsKeyDown(Keys.Left) && currentKeyboardState.IsKeyDown(Keys.Space)) player.Dash("dashLeft"); if (currentKeyboardState.IsKeyDown(Keys.Right) && currentKeyboardState.IsKeyDown(Keys.Space)) player.Dash("dashRight"); if (currentKeyboardState.IsKeyDown(Keys.Up) && currentKeyboardState.IsKeyDown(Keys.Space)) player.Dash("dashUp"); if (currentKeyboardState.IsKeyDown(Keys.Down) && currentKeyboardState.IsKeyDown(Keys.Space)) player.Dash("dashDown"); // Stop movement if (!left && !right && !up && !down) player.Move("stop"); }