Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
void setup() {
  //set the size of the window
  size(400, 400);
  frameRate(30);
}

void draw() {

  //hides cursor
  noCursor();

  //remains static
  background (0, 38, 87); //(2+mouseY/6, 12+mouseX/3, 22+mouseX/2);

  //set Mode
  ellipseMode(CENTER);
  rectMode(CORNERS);
  noStroke();

  ///////////////////////////////////////////////////
  //Sun
  fill  (150,150,0); //(mouseX-21, mouseY-41, mouseY-119); //sun ball
  ellipse(30, 40, 120, 120);

  ///////////////////////////////////////////////////
  //City
  fill(50);
  rect(0, 320, 400, 400); //bottom block
  rect(0, 300, 90, 320); //left definition block
  rect(160, 310, 180, 320); // middle definition
  rect(220, 300, 310, 320); //right definition

  //buildings from left to right
  rect(0, 240, 40, 320); //left
  rect(50, 190, 90, 320);
  rect(120, 260, 160, 320);
  rect(180, 220, 220, 320);
  rect(260, 180, 300, 320);
  rect(310, 220, 350, 320);
  rect(370, 240, 400, 320); //right

  //windows from left to right
  fill (230);
  rect(10, 290, 20, 300); //left
  rect(20, 250, 30, 260);
  rect(60, 220, 70, 230);
  rect(70, 290, 80, 300);
  rect(130, 270, 140, 280);
  rect(140, 300, 150, 310);
  rect(190, 270, 200, 280);
  rect(200, 240, 210, 250);
  rect(270, 190, 280, 200);
  rect(280, 260, 290, 270);
  rect(320, 250, 330, 260);
  rect(330, 270, 340, 280);
  rect(380, 310, 390, 320);
  rect(390, 250, 400, 260); //right

  //road
  fill(30);
  rect(0, 360, 400, 400); //black road
  fill(150);
  rect(0, 377, 400, 380); //white stripe

  ///////////////////////////////////////////////////  
  //UFO dome
  fill(200);
  ellipse(mouseX, mouseY-10, 40, 40); //dome
  fill(250);
  ellipse(mouseX-10, mouseY-20, 5, 10); //highlight

  //Alien
  fill(0, 150, 30, 240);
  ellipse(mouseX, mouseY-20, 10, 10); //head
  ellipse(mouseX, mouseY-10, 5, 10); //body

  //UFO body
  fill(0, 100, 100);
  ellipse(mouseX-30, mouseY, 20, 20); //left side of body
  ellipse(mouseX+30, mouseY, 20, 20); //right side of body
  rect(mouseX-30, mouseY-10, mouseX+30, mouseY+10); //main body

  //UFO body lights
  //lights change colour with mouse movement
  fill(mouseX, mouseY,0);
  ellipse(mouseX-30, mouseY, 5, 5); //left to right
  ellipse(mouseX-10, mouseY, 5, 5);
  ellipse(mouseX+10, mouseY, 5, 5);
  ellipse(mouseX+30, mouseY, 5, 5);
}
///////////////////////////////////////////////////
void mousePressed () {
  //beam of light flashes
  fill(170, 170, 0);
  triangle(mouseX, mouseY, mouseX+30, mouseY+40, mouseX-30, mouseY+40);
}

void keyPressed() {
  println("Bow before Zorg");
}