20th Feb 2019, 11:26 PM
Twaatii
Twaatii - avatar
2 Answers
+ 5
calling circle.update(); is useless. you should call it using an object of circle like circleArray[a number]. update() it's already done through the loop. for collisions there is already a collision logic, but it's used for the walls ( borders of the canvas) you can use a comparison of the x position and the radius of each circle to determine a collision or a function that calculate the distance between circles. and set a particular distance to be detected as a collision. the formula to find the distance is: var a =circle1.x-circle2.x; var b = circle1. y - circle2.y; var distance = Math.sqrt( a*a + b*b );
21st Feb 2019, 12:21 AM
Bahha┣
Bahha┣ - avatar
+ 2
You have created such a complex code and do not know how to make collisions? 😕
20th Feb 2019, 11:46 PM
Solo
Solo - avatar