Advertisement
Guest User

Untitled

a guest
Dec 2nd, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.62 KB | None | 0 0
  1. double left = //rectangle's most left coordinate
  2. double bottom = //rectangle's most bottom coordinate
  3. //etc
  4. double centerX = //player (circle) center X coordinate
  5. double centerY //it's y coord
  6. double radius //radius of the circle
  7.  
  8. if(((left-centerX)*(left-centerX)+(bottom-centerY)*(bottom-centerY))<radius){
  9. //it is intersecting
  10. }
  11.  
  12. double r0 //radius of player
  13. double r1 //radius of shape
  14. double x0 //center X of player
  15. double x1 //center X of shape
  16. double y0 //center Y of player
  17. double y1 //center Y of shape
  18.  
  19. double DX = x1 - x0;
  20. double DY = y1 - y0;
  21. double D = Math.hypot(DX, DY);
  22. if(D<r0+r1){
  23. //They are intersecting
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement