I am using a script to generate random particles within a circle based on it's radius. What I would like to do next is detect when the particle collides with the circles edge.
I'm guessing I need to use a for loop to store the coordinates of the circles circumference in an array but I'm unsure what math is needed to do this.
Here's what I've got down from the answer below. It doesn't seem to be working though:
Variable par is a particles moving with the circle, emitters contains x,y, positions of the centre of the circle while the prop height contains the radius.
var fromC = Math.sqrt( (par.y-(emitters[i].y ) )^2 + (par.x- (emitters[i].x))^2);
if(fromC >= emitters[i].height){
par.vx *= -1;
par.vy *= -1;
}
Thanks in advance.