I was playing and mixed ofNoise and the ofBall example on the of tutorials page . I wanted to manipulate the balls in such a way that they stay away(80 pixels something) from the centre of the screen . I was able to do it by calculating the distance b/w the centre and the ball and then change the direction of the ball.
if(ofDist(x, y, ofGetWidth()/2, ofGetHeight()/2) <80){
x *= -1;
y *= -1;
}
The direction change in the balls is too abrupt in this case and it feels like there is a black ball in the middle that is forcing the small balls outward . How can i achieve the direction change in such a way that it feels like the ball is smoothly deflected . Something like “ofNoise is to ofRandom” :
if(ofDist(x, y, ofGetWidth()/2, ofGetHeight()/2) <80){
// smoothly deflect the ball
// ok to have a slightly inward smooth trajectory like a curve
}
Here is the screenshot without the change in direction :
With the ofDist condition change in direction:
I don’t know why i am not able to upload a zip file containing the video , every time i try to upload the zip file,
it gives me an error that the “image size is too big 3072kb” but both the files are less than 2000kb??
Edit : I forgot to mention that the particles already changing directions with ofNoise mapped to the x and y co-ordinate
of the cirlces.
Thanks !