Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2024
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. void Player::Jump()
  2. {
  3.     if (!peakJumpPoint)
  4.         peakJumpPoint = body.y - jumpHeight;
  5. }
  6.  
  7. void Player::ApplyJumpMotion()
  8. {
  9.     // If jumping (peakJumpPoint should be 0 if not jumping)
  10.     if (peakJumpPoint)
  11.     {
  12.         if (body.y <= peakJumpPoint)
  13.         {
  14.             if (jumpCalls >= game::maxJumpCalls)
  15.             {
  16.                 shouldFall = true;
  17.                 peakJumpPoint = 0;
  18.                 jumpCalls = 0;
  19.             }
  20.             else
  21.                 jumpCalls++;
  22.         }
  23.         else
  24.         {
  25.             shouldFall = false;
  26.             body.y -= jumpSpeed;
  27.         }
  28.  
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement