class Building { float w, d, h, g; int stories; int age = 0; float xc[] = new float[1]; float yc[] = new float[1]; float zc[] = new float[1]; float vx[] = new float[1]; float vy[] = new float[1]; float vz[] = new float[1]; float ix = random(-.5,.5); float iz = random(-.5,.5); //boolean bd[] = new boolean[1]; float cx = 0; float cy = 0; float cz = 0; float ox = 0; float oy = 0; float oz = 0; boolean receptive = true; int[] bd = new int[1]; int agelimit = 1300; Building(float wide,float deep, float high, int st, float grav) { w = wide; h = high; d = deep; stories = st; g = grav; bd[0] = 0; println("stories="+stories); for(int i =0; i < stories; i++) { for(int j =0; j < 4; j++) { bd = append(bd, 0); if(j == 0) { xc = append(xc,ox); yc = append(yc,oy); zc = append(zc,oz); vx = append(vx,random(-.1,.1)+ix); vy = append(vy,0); vz = append(vz,random(-.1,.1)+iz); } if(j == 1) { xc = append(xc,ox); yc = append(yc,oy); zc = append(zc,oz-d); } if(j == 2) { xc = append(xc,ox+w); yc = append(yc,oy); zc = append(zc,oz-d); } if(j == 3) { xc = append(xc,ox+w); yc = append(yc,oy); zc = append(zc,oz); } oy-=h; } // println(xc); } } void move() { cx = 0; cy = 0; cz = 0; for(int i = 0; i < stories; i++) { xc[i]+=vx[i]; yc[i]-=vy[i]; zc[i]+=vz[i]; vy[i]-=g; cx+= xc[i]; cy+= yc[i]; cz+= zc[i]; if(yc[i] > 0) { yc[i] = 0; vy[i]*=-.5; vx[i]*=random(-1,1); vz[i]*=random(-1,1); bd[i]++; } if(abs(vx[i])<.1 && abs(vy[i])<.1 && abs(vz[i])<.1 && bd[i] == 10) { vx[i] = 0; vy[i] = 0; vz[i] = 0; receptive = false; } if(pressed && receptive) { vy[i]+=random(.031); } if(receptive && mpressed) { vy[i]+=random(.000); } } cx/=stories; cy/= stories; cz/= stories; } void display() { age++; if(age < agelimit) { println(stories); //println("hello"); //print(xc); //box(5,5,5); fill(150,30,30,255); stroke(190,20,0); //beginShape(TRIANGLE_STRIP); //why the hell this for looop needs to go to stories - 5 is way beyond me. for(int i = 0; i < stories-5; i++) { beginShape(QUAD); vertex(xc[i],yc[i],zc[i]); vertex(xc[i+4],yc[i+4],zc[i+4]); vertex(xc[i+5],yc[i+5],zc[i+5]); vertex(xc[i+1],yc[i+1],zc[i+1]); endShape(); //println("hithere"); } //endShape(); noFill(); noStroke(); if(age > agelimit-xc.length) { xc = shorten(xc); yc = shorten(yc); zc = shorten(zc); } } } void shadow() { pushMatrix(); scale(1,.02,1); translate(0,8.13,0); age++; if(age < agelimit) { println(stories); //println("hello"); //print(xc); //box(5,5,5); fill(20,0,0,255); noStroke(); //stroke(190,20,20); beginShape(QUAD_STRIP); for(int i = 0; i < stories; i++) { vertex(xc[i],0,zc[i]); //println("hithere"); } endShape(); noFill(); } popMatrix(); } }