xxxxxxxxxx
79
let x=0;
let y=1024;
let ng;
var position;
var velocity;
var r = 6;
var speed = 3.5;
function setup() {
createCanvas(1024, 768);
}
function draw() {
background(color(100, 100, 200));
neighborhood(x+680, y+200);
neighborhood(x+500, y+300);
neighborhood(x+200, y+100);
neighborhood(x+50, y+300);
XLneighborhood(x+350, y+350);
XLneighborhood(x+830, y+400);
grow();
show();
}
function building(x, y, ng){
quad(x+3*ng, y, x+3*ng, height, x-3*ng, height, x-3*ng, y);
quad(x+3*ng, y, x, y+2*ng, x-3*ng, y, x, y-2*ng);
}
function neighborhood(x, y, ng){
building(x+120, y+120, 10);
building(x, y+110, 10);
building(x+60, y, 10);
building(x+30, y+250, 10);
building(x+90, y+200, 10);
}
function XLneighborhood(x, y, ng){
building(x+240, y+140, 20);
building(x, y+130, 20);
building(x+120, y, 20);
building(x+60, y+270, 20);
building(x-60, y+200, 20);
}
function grow(){
if (y > 200) {
y = y - 2 +random(-5, 2);
x = x +random(-2, 2);
}
if (y > 100) {
y = y - 1 +random(-3, 1);
x = x +random(-2, 2);
}
if (y > 0) {
y = y - 0.4 +random(-1, 1);
x = x +random(-1, 1);
}
}
function grow2(){
y = y - 3;
// x = x +random(-1, 1);
// y = y +2 +random(-1, 1);
// how to make this work?! please
}
function show(){
colorMode(RGB);
stroke (50, 50, 70, 180);
strokeWeight(2);
fill(200, 200, 200, 245);
}