// Seung Joon Choi // http://epicure.graffity.net // epicure@hanmail.net // 2005.10.14. class Bldg { Bldg() { wx = 50 + random(50); wy = 50 + random(50); h = 0; r = sqrt(wx*wx + wy*wy) + 10 + random(20); angle = random(1) * TWO_PI; z = 0; cH = random(1); cS = 0.01; cB = 0.5 + random(0.5); cA = 0; } void Init(Bldg[] blds) { for(int i = 0; i < blds.length; i++) { Bldg bld = blds[i]; if(this != bld) { float dx = x - bld.x; float dy = y - bld.y; float d = sqrt(dx*dx + dy*dy); float R = r * 1.5 + bld.r * 1.5; if(d < R) { float k = R - d; x += k * dx / d; y += k * dy / d; } } } } void Interact(PLife[] pls) { for(int i = 0; i < pls.length; i++) { PLife pl = pls[i]; float dx = x - pl.x; float dy = y - pl.y; float d = sqrt(dx*dx + dy*dy); pl.z *= 0.9; if(d < r * 0.8) { pl.X = x; pl.Y = y; h += 0.1; cA += 0.01; cS = 0.001; if(d < r * 0.4) { pl.vx *= 0.2; pl.vy *= 0.2; cS = 0.1; cH = hue(pl.c); if(cA > 0.9) { pl.z = h; } if(pl.mental_barrier < 0.2) { pl.X = x; pl.Y = y; } } } } h *= 0.999; cA *= 0.99; } void Render() { stroke(0, 0, 0, cA * 0.01); fill(cH, cS, cB, cA); pushMatrix(); translate(x, y, z); //ellipse(0, 0, r, r); rotateZ(angle); beginShape(QUADS); vertex(-wx, -wy, h); vertex(-wx, wy, h); vertex(wx, wy, h); vertex(wx, -wy, h); vertex(-wx, -wy, 0); vertex(-wx, wy, 0); vertex(-wx, wy, h); vertex(-wx, -wy, h); vertex(-wx, wy, 0); vertex(wx, wy, 0); vertex(wx, wy, h); vertex(-wx, wy, h); vertex(wx, wy, 0); vertex(wx, -wy, 0); vertex(wx, -wy, h); vertex(wx, wy, h); vertex(wx, -wy, 0); vertex(-wx, -wy, 0); vertex(-wx, -wy, h); vertex(wx, -wy, h); endShape(); popMatrix(); } float wx, wy, h; float r; float angle; float x, y, z; int c; float cH, cS, cB, cA; }