twosy2
YaBB Newbies
Offline
Posts: 1
Confusing Variables - motion
Mar 17th , 2010, 8:31am
I am pretty new to processing and this problem is driving me crazy. What I want is to have 5 circles moving from the top of the screen to the bottom at different places. When you move over one of the circles it changes into some text at the bottom. Each circle corresponds to a different word in a sentence. I figured out that part using a boolean , but the problem is how to make 5 moving circles without rewriting so much code. I set up the function (circle) to control the different variables. And it looks like it works when I run it, but the circleX1, and circleY1 stay at 0,0! (just in spirit. It moves normally) So the boolean only turns true when it's on 0, 0, rather than on the moving circle. Am I making any sense? Here is the code showing how I set up the variables (without the boolean because then there's a ton of other code I would need to add) How can I fix this? float beginx ; float beginy; float endx; float endy; float distx; float disty; float step; float pct =0.0; float circleX1 = 0; float circleY1 =0; float circleRadius1 =30; float circleX2 =0; float circleY2 =0; float circleRadius2 =20; void setup(){ size(480, 320); smooth(); noStroke(); } void draw(){ background(0); circle(circleX1,circleY1,circleRadius1,0,0,100,100,0.0004); circle(circleX2,circleY2,circleRadius2,0,0,200,100,0.002); } void circle(float x,float y,float r, float bx,float by, float ex,float ey,float s){ beginx =bx; beginy =by; endx = ex; endy =ey; step = s; distx =endx-beginx; disty = endy-beginy; pct+=step; if (pct <1.0){ x = beginx +(pct*distx); y = beginy +(pct*disty); } if (pct>=1){ pct=0; } ellipse(x,y,r,r); ////////I think this is where the issue is....but I don't know why }