float degree; boolean mouseaction; Foo foo[]; void setup(){ size(320,240); framerate(40); degree = 0; foo = new Foo[336]; int count = 0; for(int i=0;i<21;i++){ for(int j=0;j<16;j++){ foo[count] = new Foo(16*i, 16*j, 0, count); count++; } } } void loop(){ background(255); degree+=.1; translate(0,0,10); for(int i=0;i<336;i++)foo[i].update(); int row = 0; int i = 0; for(int j=0; j<300; j++){ beginShape(QUADS); vertex(foo[i].x2, foo[i].y2, foo[i].z); vertex(foo[i+1].x2, foo[i+1].y2, foo[i+1].z); vertex(foo[i+17].x2, foo[i+17].y2, foo[i+17].z); vertex(foo[i+16].x2, foo[i+16].y2, foo[i+16].z); endShape(); i++; if(i == 15+(16*row)){ i++; row++; } } } void mousePressed(){ mouseaction = true; } void mouseReleased(){ mouseaction = false; } class Foo{ float x, y, z, x2, y2, distance; int count; Foo(float X, float Y, float Z, int C){ x = X; y = Y; z = Z; count = C; } void update(){ if (mouseaction == true){ distance = dist(mouseX,mouseY,x,y); constrain(distance, 0, 200); }else{ distance = 200; } x2 = x+(random(-1,1)*distance/10); y2 = y+(random(-1,1)*distance/10); z = cos(degree+count)*sin(degree+count)*20; } }