Advertisement
Guest User

Untitled

a guest
Nov 20th, 2014
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.08 KB | None | 0 0
  1. //change for # of houses
  2. float scaler = 20;
  3.  
  4. //change for speed
  5. float speed = 0.1;  
  6.  
  7.  
  8. float theta;
  9. float sunlight;
  10. float shadows;
  11. float mapper;
  12.  
  13.  
  14. void setup() {
  15.   size(displayWidth, displayHeight);
  16. }
  17.  
  18. void draw() {
  19.  
  20.   translate(mouseX-20, mouseY-20);
  21.   scale(1/scaler);
  22.  
  23.   theta += speed;
  24.  
  25.   sunlight=map(sin(theta), -1, 0.7, 1.5, 0);
  26.   shadows=map(sunlight, 1.5, 0, 1, 0.6);
  27.   mapper=map(mouseX, 0, displayWidth, 5, -5);
  28.  
  29.   //
  30.   if (mousePressed==true) {
  31.   } else {
  32.  
  33.     background(50*sunlight, 122*sunlight, 255*sunlight);
  34.   }
  35.   for (int i = 0; i < scaler; i++) {
  36.  
  37.     for (int j = 0; j <= scaler; j++) {
  38.       pushMatrix();  
  39.       translate(i*width*mapper*cos(theta)/10, j*width*mapper*cos(theta)/10);  
  40.       rotate(theta);
  41.       house();
  42.       popMatrix();
  43.     }
  44.   }
  45. }
  46. void house() {
  47.  
  48.   noStroke();
  49.   fill(255*sunlight, 255*sunlight, 51*sunlight, sunlight*255);
  50.   ellipse(width/1.2*cos(theta)+(width/2), height/1.2*sin(theta)+(height/1.5), 100, 100);
  51.  
  52.   //terrain
  53.   fill(51*shadows, 204*shadows, 51*shadows);
  54.   rect(0, width/2, width, height/2);
  55.  
  56.   fill(204*shadows, 255*shadows, 204*shadows);
  57.   quad(400, 600, 575, 600, 625, 800, 350, 800);
  58.  
  59.  
  60.   fill(170*shadows, 170*shadows, 170*shadows);
  61.   rect(0, height/1.5, width, height/5);
  62.   fill(244, 244, 244);
  63.   rect(20, 800, 120, 12 );
  64.   rect(320, 800, 120, 12 );
  65.   rect(620, 800, 120, 12 );
  66.   rect(920, 800, 120, 12 );
  67.   rect(1220, 800, 120, 12 );
  68.   rect(1520, 800, 120, 12 );
  69.  
  70.  
  71.   //House
  72.   fill(204*shadows, 102*shadows, 0);
  73.   rect(100, 200, 800, 400);
  74.  
  75.   //roof
  76.   fill(208*shadows, 33*shadows, 33*shadows);
  77.   triangle(75, 200, 500, 25, 925, 200);
  78.  
  79.   // windows
  80.   fill(25/shadows, 50/shadows, 75/shadows);
  81.   rect(150, 250, 75, 120);
  82.   rect(150+100, 250, 75, 120);
  83.  
  84.   rect(400, 250, 75, 120);
  85.   rect(400+100, 250, 75, 120);
  86.  
  87.   rect(675, 250, 75, 120);
  88.   rect(675+100, 250, 75, 120);
  89.  
  90.   rect(675, 425, 75, 80);
  91.   rect(675+100, 425, 75, 80);
  92.  
  93.   rect(150, 425, 175, 100);
  94.  
  95.   //Door
  96.   fill(102, 51, 0);
  97.   rect(400, 425, 175, 175, 8, 8, 0, 0);
  98.   fill(0);
  99.   rect(487, 425, 3, 175);
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement