import processing.opengl.*; int numbldgs = 0; int ex = 0; float orbitx = 0.0; float orbitz = 0.0; float orbity = 0.; float inc = .1; boolean constructing = false; Building[] bldg = new Building[1]; //------------------------setup---------------------- void setup() { size(800,450,P3D); hint(ENABLE_OPENGL_2X_SMOOTH); lights(); //smooth(); strokeWeight(1); // noFill(); fill(80,0,0,115); background(0); bldg[0] = new Building(0,0,0,0,0,0,0.); // bldg[0].shite = 10; // bldg[0].stories = 10; // bldg[0].speed = 10; // noLoop(); } //----------------------draw------------------------- void draw() { // strokeWeight((random(1,3))); lights(); pointLight(251, 202, 226, -3500, 40, 36); background(0); rotateX(PI/2); rect(-1000,-1000,2000,2000); inc+=.002; orbitx = sin(inc)*300; orbitz = cos(inc)*300; orbity = -100-(sin(inc*4)*50); camera(orbitx,orbity,orbitz,0,-80,0,0,1,0); if(constructing) { int high = int(random(5,20)); int story = int(random(5,20)); int wide = int(random(5,40)); int deep = int(random(5,40)); Building b = new Building(high,story,wide,deep,(random(-1,1)),random(-1,1),0.); bldg = (Building[]) append(bldg,b); } for (int i = 0; i < bldg.length; i++) { bldg[i].move(); bldg[i].construct(); } } //--------------------------------------------------- void mousePressed() { constructing = true; int high = int(random(5,20)); int story = int(random(5,20)); int wide = int(random(5,40)); int deep = int(random(5,40)); Building b = new Building(high,story,wide,deep,(random(-1,1)),random(-1,1),0.); bldg = (Building[]) append(bldg,b); } void mouseReleased() { constructing = false; } //------------------------------------------------------------------- //----------------------------building class ------------------------ class Building { int stories, wide,deep, r, g, b; float shite, ex2, ex3, speed, speed2; Building(float high, int st, int w, int d, float sp, float sp2, float x) { shite = high; stories = st; wide = w; deep = d; speed = sp; speed2 = sp2; ex3 = x; r = int(random(160)); g = int(random(255)); b = int(random(255)); } void move() { ex3+=speed; ex2+=speed2; if(shite > 0) { shite-=.01; } } void construct() { stroke(r,20,20,100); //fill(r,20,20,115); if(shite >.8) { pushMatrix(); translate(ex2,0,ex3); int tx = 0; strokeWeight(random(1,2)); for(int i=0;i< stories;i++) { translate(0,-shite,0); box(wide,shite,deep); } popMatrix(); } } }