Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double left = //rectangle's most left coordinate
- double bottom = //rectangle's most bottom coordinate
- //etc
- double centerX = //player (circle) center X coordinate
- double centerY //it's y coord
- double radius //radius of the circle
- if(((left-centerX)*(left-centerX)+(bottom-centerY)*(bottom-centerY))<radius){
- //it is intersecting
- }
- double r0 //radius of player
- double r1 //radius of shape
- double x0 //center X of player
- double x1 //center X of shape
- double y0 //center Y of player
- double y1 //center Y of shape
- double DX = x1 - x0;
- double DY = y1 - y0;
- double D = Math.hypot(DX, DY);
- if(D<r0+r1){
- //They are intersecting
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement