/// <summary> /// Handles all player movement /// Is called on every frame update /// </summary> public void movement(Game game) { //Get the current keyboard state var keyState = OpenTK.Input.Keyboard.GetState(); //Call method to handle gravity (and other vertical environmental forces) fall(); //If the user presses escape, close the game if (keyState[Key.Escape]) { game.Close(); } //Call the method to handle grab state management grab(keyState[Key.Left], keyState[Key.Right], keyState[Key.Up]); //Call the method to handle left and right motion, and pass true or false for left and right arrow keys move(keyState[Key.Left], keyState[Key.Right]); //Call the methods to handle jumping and air state refreshing jump(keyState[Key.Space], keyState[Key.Left], keyState[Key.Right]); stateRefresh(keyState[Key.Space], keyState[Key.LShift] || keyState[Key.RShift]); //Call the method to handle dashing dash(keyState[Key.LShift] || keyState[Key.RShift], keyState[Key.Left], keyState[Key.Right], keyState[Key.Down]); //Call the method to handle horizontal environmental forces (friction, etc) decelerate(keyState[Key.Left], keyState[Key.Right]); //Update the character position position += velocity; }
/// <summary> /// Handles all player movement /// Is called on every frame update /// </summary> public void movement(Game game) { //Get the current keyboard state var keyState = OpenTK.Input.Keyboard.GetState(); //Call method to handle gravity (and other vertical environmental forces) fall(); //If the user presses escape, close the game if (keyState[Key.Escape]) game.Close(); //Call the method to handle grab state management grab(keyState[Key.Left], keyState[Key.Right], keyState[Key.Up]); //Call the method to handle left and right motion, and pass true or false for left and right arrow keys move(keyState[Key.Left], keyState[Key.Right]); //Call the methods to handle jumping and air state refreshing jump(keyState[Key.Space], keyState[Key.Left], keyState[Key.Right]); stateRefresh(keyState[Key.Space], keyState[Key.LShift] || keyState[Key.RShift]); //Call the method to handle dashing dash(keyState[Key.LShift] || keyState[Key.RShift], keyState[Key.Left], keyState[Key.Right], keyState[Key.Down]); //Call the method to handle horizontal environmental forces (friction, etc) decelerate(keyState[Key.Left], keyState[Key.Right]); //Update the character position position += velocity; }