import krister.Ess.*; float a = 100; float x = random(0, width); float y = random(0, height); float r = random(0, 5); boolean gameover = false; Background bg = new Background(); float[] segx = new float[20]; float[] segy = new float[20]; float segLength = 0; ArrayList circles = new ArrayList(); void setup() { size(400, 400); stroke(255); smooth(); circles.add(new CrazyCircle()); frameRate(60); } class Background { float r, g, b; float step = 5; Background() { r = random(0,256); g = random(0,256); b = random(0,256); } void update() { r += random(-step, step); g += random(-step, step); b += random(-step, step); } void render() { background(r, g, b); } } //boolean class CrazyCircle { float x, y, h, s, life; float r, g, b, a; float step; CrazyCircle() { x = random(0, width); y = random(0, height); r = random(0, 256); g = random(0, 256); b = random(0, 256); a = random(0, 2); step = random(0, 10); h = 0; s = random(0.1, 2.5); } void update() { h += s; r += random(-step,step); g += random(-step,step); b += random(-step,step); a += random(0, a); strokeWeight(5); stroke(0, 100); fill(r, g, b, a); ellipse(x, y, h, h); } boolean isDead() { if( h > width || h > height) return true; return false; } boolean isClicked( int mx, int my) { if( ((x-mx) * (x-mx)) + ((y-my) * (y-my)) <= ((h/2) * (h/2))) return true; return false; } } void draw() { bg.render(); if(!gameover) { for(int i = 0; i < circles.size(); ++i) { CrazyCircle temp = (CrazyCircle)circles.get(i); temp.update(); if(temp.isDead() ) { gameover = true; } } } else { } dragSegment(0, mouseX, mouseY); for(int i=0; i= 0; --i) { CrazyCircle temp = (CrazyCircle)circles.get(i); if(temp.isClicked(mouseX, mouseY)) { circles.remove(i); if(circles.size()<50) { ++segLength; if(segLength>20) segLength = 20; double t = random(0, 1); if(t<0.25) circles.add(new CrazyCircle()); circles.add(new CrazyCircle()); Runtime r = Runtime.getRuntime(); r.gc(); } break; } } } void dragSegment(int i, float xin, float yin) { float dx = xin - segx[i]; float dy = yin - segy[i]; float angle = atan2(dy, dx); segx[i] = xin - cos(angle) * 5 * segLength; segy[i] = yin - sin(angle) * 5 * segLength; strokeWeight(i); stroke(0, i*100); fill(i*i, 50); segment(segx[i], segy[i], angle); } void segment(float x, float y, float a) { pushMatrix(); translate(x, y); rotate(a); //line(0, 0, segLength, 0); ellipse(0,0, segLength*a, segLength*a); popMatrix(); } /**//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////