+ 2
I want to add collision to each other ???
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 );
+ 2
You have created such a complex code and do not know how to make collisions? đ