jshanh25
YaBB Newbies
Offline
Posts: 5
Re: Help, Dear god help :)
Reply #1 - May 8th , 2007, 10:25pm
I got it!!! Go me, ok heres the code: Ball[] bBalls; int MAX; int ch; float d; color c = color(0,0,0,random(255)); int n; void setup() { size(1024, 730); //frameRate(25); background(20,10); smooth(); MAX = 1000; ch = 0; bBalls = new Ball[MAX]; for (int i=0;i<MAX;i++) { bBalls[i] = new Ball(); bBalls[i].x = random(0, 1024); bBalls[i].y = random(0, 730); bBalls[i].vx = random(3,5); bBalls[i].vy = random(-4,4.25); bBalls[i].d = d+i; bBalls[i].c = color(255,0,0); bBalls[i].c2 = color(0,255,255); bBalls[i].z = i-.8 /0.08; bBalls[i].fil = c; n=i; } } void draw() { for (int i=0;i<ch;i++) { bBalls[i].run(); } } class Ball { float x; float y; float vx; float vy; float d; float z; color fil; color c = color(255,0,0,random(100)); color c2= color(0,255,255,random(100)); void run() { if (key == '1'){ bBalls[2].d=50; c = color(10,10,10,random(100)); } else if (key == '2'){ d = 10; } drawShape(); x = x + vx; y = y + vy; if (x < 0 || x > width) { vx = -vx; } if (y < 0 || y > height) { vy = -vy; } } void drawShape() { ellipseMode(CENTER_RADIUS); strokeWeight(1); noFill(); //fill(0,100); stroke(c2); ellipse(x, y, d, d); fill(fil); stroke(c); ellipse(x+z,y,d,d); } } void mousePressed() { ch = ch+1; } --------------------------------------- The magical cure was to add the: if (key == '1'){ bBalls[2].d=50; } else if (key == '2'){ d = 10; ...In the void run(), the '1' key changes only the second ellipse, while the '2' key will change all of them. Good times.