|
Author |
Topic: bubble reincarnation (Read 1014 times) |
|
benelek
|
bubble reincarnation
« on: Jan 5th, 2003, 6:09am » |
|
i made some modifications on the Object script in the Reference section (written by the Proce55ing team, i'm guessing). bubble reincarnation! http://users.bigpond.net.au/schwartz/bubbleReincarnation/applet/index.ht ml enjoy //Bubble Reincarnation // by benelek // (modified from the Object reference by Proce55ing) // // a group of bubbles is given a lifetime; // in which they wither and die; // all the while pursued by // a relentless group of strait lines! // they, too, wither and die; // but rejoin in their next life. // int num = 30; BCircle[] bc = new BCircle[num]; HLines[] hl = new HLines[num]; int maxsize = 15; void setup() { size(200, 200); background(255); ellipseMode(CENTER_RADIUS); for(int i=0; i<num; i++) { bc[i] = new BCircle(random(0, width), random(0, height), random(2, maxsize), maxsize); hl[i] = new HLines(random(0, height), random(0, 1)); } } void loop() { for(int i=0; i<num; i++) { bc[i].update(); hl[i].update(); bc[i].draw(); hl[i].draw(); } } class BCircle { float x, y, size, max; float speed = random(1); int age=0; BCircle (float ix, float iy, float isize, int imax) { x = ix; y = iy; size = isize; max = imax; } void update() { if(age*speed<255) { x += random(-size/max, size/max); y += random(-size/max, size/max); if (x > width+size) { x = -size; } if (x < -size) { x = width+size; } if (y > height+size) { y = -size; } if (y < -size) { y = height+size; } age++; } else { age=0; x = random(width); y = random(height); } } void draw() { stroke(age*speed); ellipse(x, y, size, size); } } class HLines { float y, speed; int bubID = int(random(num-1)); HLines (float iy, float ispeed) { y = iy; speed = ispeed; } void update() { if( bc[bubID].y < y) { y -= speed; } else { y += speed; } } void draw() { stroke(bc[bubID].age*bc[bubID].speed); line(0, y, width, y); } }
|
|
|
|
|