Example #1
0
 /// <summary>
 /// Updates the position of the player based on the up, down, left, and right keys.
 /// </summary>
 /// <param name="theKBState">The current state of the Keyboard.</param>
 private void UpdateKBMovement(KeyboardState theKBState)
 {
     if (theKBState.IsKeyDown(Keys.Up))
     {
         MyGameControl.MovePlayer(0, -(int)(MyGameControl.MyPlayer.Velocity));
     }
     if (theKBState.IsKeyDown(Keys.Right))
     {
         MyGameControl.MovePlayer((int)(MyGameControl.MyPlayer.Velocity), 0);
     }
     if (theKBState.IsKeyDown(Keys.Down))
     {
         MyGameControl.MovePlayer(0, (int)(MyGameControl.MyPlayer.Velocity));
     }
     if (theKBState.IsKeyDown(Keys.Left))
     {
         MyGameControl.MovePlayer(-(int)(MyGameControl.MyPlayer.Velocity), 0);
     }
 }