Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //change for # of houses
- float scaler = 20;
- //change for speed
- float speed = 0.1;
- float theta;
- float sunlight;
- float shadows;
- float mapper;
- void setup() {
- size(displayWidth, displayHeight);
- }
- void draw() {
- translate(mouseX-20, mouseY-20);
- scale(1/scaler);
- theta += speed;
- sunlight=map(sin(theta), -1, 0.7, 1.5, 0);
- shadows=map(sunlight, 1.5, 0, 1, 0.6);
- mapper=map(mouseX, 0, displayWidth, 5, -5);
- //
- if (mousePressed==true) {
- } else {
- background(50*sunlight, 122*sunlight, 255*sunlight);
- }
- for (int i = 0; i < scaler; i++) {
- for (int j = 0; j <= scaler; j++) {
- pushMatrix();
- translate(i*width*mapper*cos(theta)/10, j*width*mapper*cos(theta)/10);
- rotate(theta);
- house();
- popMatrix();
- }
- }
- }
- void house() {
- noStroke();
- fill(255*sunlight, 255*sunlight, 51*sunlight, sunlight*255);
- ellipse(width/1.2*cos(theta)+(width/2), height/1.2*sin(theta)+(height/1.5), 100, 100);
- //terrain
- fill(51*shadows, 204*shadows, 51*shadows);
- rect(0, width/2, width, height/2);
- fill(204*shadows, 255*shadows, 204*shadows);
- quad(400, 600, 575, 600, 625, 800, 350, 800);
- fill(170*shadows, 170*shadows, 170*shadows);
- rect(0, height/1.5, width, height/5);
- fill(244, 244, 244);
- rect(20, 800, 120, 12 );
- rect(320, 800, 120, 12 );
- rect(620, 800, 120, 12 );
- rect(920, 800, 120, 12 );
- rect(1220, 800, 120, 12 );
- rect(1520, 800, 120, 12 );
- //House
- fill(204*shadows, 102*shadows, 0);
- rect(100, 200, 800, 400);
- //roof
- fill(208*shadows, 33*shadows, 33*shadows);
- triangle(75, 200, 500, 25, 925, 200);
- // windows
- fill(25/shadows, 50/shadows, 75/shadows);
- rect(150, 250, 75, 120);
- rect(150+100, 250, 75, 120);
- rect(400, 250, 75, 120);
- rect(400+100, 250, 75, 120);
- rect(675, 250, 75, 120);
- rect(675+100, 250, 75, 120);
- rect(675, 425, 75, 80);
- rect(675+100, 425, 75, 80);
- rect(150, 425, 175, 100);
- //Door
- fill(102, 51, 0);
- rect(400, 425, 175, 175, 8, 8, 0, 0);
- fill(0);
- rect(487, 425, 3, 175);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement