Where do all my circles go?
in
Programming Questions
•
1 years ago
So I wanted to make the "Processing" sketch... like the one at the top of this forum (and in a lot of other places). Basically I completely copied Bouncy Bubbles almost word for word when I was trying to get objects to interact with each other... So then I was messing around with it and I made the circles move and put different formulas in it.
When I added this:
if(frameCount>2){ //I think this helps it not be so bizarre in the beginning
xm = xm + .1/(x-others[i].x); //formula that makes things push away from each other
ym = ym + .1/(y-others[i].y);
}
Inside the for loop:
for (int i=id+1;i<zarray.length;i++) { //id is an id given to each object. zarray is an array of my class Z
I think maybe the circles are equaling and canceling out because a lot of them hold pretty still, until one of them shoots across the screen.
Anyways it looks like I lose a bunch of circles so I guess some of them manage to escape my if()'s on the walls. I also said:
if(x<-10 || x>width+10){ //if it leaves the screen
x=width/2;
y=height/2;
xm=random(-10,10);
ym=random(-10,-10);
}
under void move
I don't know what happens to them, and only happens most of the time. If you want to see the sketch or source its
here... but it's kind of screwy on the page.
Any thoughts are appreciated!
1