Advertisement
Guest User

Untitled

a guest
Apr 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. int collision( void * sp1 , void * sp2 , int dx , int dy)
  2. {
  3. SPR_PTR b1 = sp1 , b2 = sp2 ;
  4. if ((b1->x > b2->x + b2->w - 1) || // is b1 on the right side of b2?
  5. (b1->y > b2->y + b2->h - 1) || // is b1 under b2?
  6. (b2->x > b1->x + b1->w - 1) || // is b2 on the right side of b1?
  7. (b2->y > b1->y + b1->h - 1)) // is b2 under b1?
  8. {
  9. // no collision
  10. return 0;
  11. }
  12.  
  13. // collision
  14.  
  15. return 1 ;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement