Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. Vector2 pos = ball.position;
  2. Vector2 prevPos = ball.previousPosition; // You'll have to keep track of where the ball was 1 frame ago.
  3.  
  4. for (int i=0; i<COLLISION_PRECISION; i++)
  5. {
  6. Vector2 testPos = lerp(prevPos, pos, i/COLLISION_PRECISION);
  7. if (PointInsideRect(testPos, paddleRect))
  8. {
  9. ball.position = testPos;
  10. // Do any collision reactions
  11. break;
  12. }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement