0

how to draw Two circle ? and how to have collision ? :(

22nd Dec 2016, 3:39 PM
Mhamed Hayssam
Mhamed Hayssam - avatar
3 Antworten
+ 2
You set javascript and java tags to your question, but both are totally different: for wich of this do you need help ? In the other hand, if by "how to have collision" you think of collision detection, I suggest you to look at the games framework and 3d/2d engines ( on all langage, without a third party framework, you've no choice but to write it from scratch )...
22nd Dec 2016, 11:04 PM
visph
visph - avatar
+ 2
Well, the second part of my previous answer is still relevant ^^ Make an algorithm for collision detection isn't difficult, especially if you treat only circles: in this case, coding your own remains possible :) You have only to know center positions and radius ( r1 and r2 ), and to compare the distance d between centers of each two circles ( or iterate over all pairs of circles combinaisons ): IF d > r1+r2 THEN the two circles do not touch, ELSE IF d < r1+r2 THEN the two circles do overlap, ELSE d == r1+r2 THEN the two circles do touch, but without overlap... And about how to draw circles, I let you search ( or wait for another answer ), because I don't have myself the response immediatly, without some researches ;) ______________ Reminder: the formula wich get the distance between two dots ( x1,y1 and x2,y2 ) is ( SQR --> square root ): d = SQR( ( x1-x2 )² + (y1-y2)² ) [ EDIT ] Think to take in account the thickness of your drawing line in addition of the radius, if it make sense...
23rd Dec 2016, 6:18 AM
visph
visph - avatar
0
In javaa
23rd Dec 2016, 5:46 AM
Mhamed Hayssam
Mhamed Hayssam - avatar