Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*Interactive Drawing assignment  "Liftoff"
 Brent Pemberton 
 To interact move mouse up and down along canvas.
 Spaceship noises optional but reccomended*/

void setup() {
  //creates the size of the window as 400 pixels by 400 pixels
  size(400, 400);
}

void draw() {
  //color of background changes depending on mouses Y position
  background(0, 0, mouseY);
  //ellipse and rectangles are Center mode
  ellipseMode(CENTER);
  rectMode(CENTER);

  //stars
  fill(250, 236, 42);
  ellipse(mouseY+190, 180, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+190, 180, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+60, 280, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+180, 80, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+140, 160, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+100, 120, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+290, 150, 5, 5);
  fill(250, 236, 42);
  ellipse(mouseY+270, 350, 5, 5);


  /* the ships "propulsion" drawn behind the
   ground so it's only visible when the ship is off the ground */
  noStroke();
  fill(250, 236, 42);
  triangle(170, mouseY, 180, mouseY+30, 190, mouseY);
  triangle(190, mouseY, 200, mouseY+30, 210, mouseY);
  triangle(210, mouseY, 220, mouseY+30, 230, mouseY);
  fill(237, 126, 93);
  triangle(170, mouseY, 190, mouseY, 180, mouseY+20);
  triangle(190, mouseY, 200, mouseY+20, 210, mouseY);
  triangle(210, mouseY, 220, mouseY+20, 230, mouseY);

  /*ground of the drawing as the ship moves closer to the bottom of the window the
  ground becomes visible */
  fill(0, 180, 0);
  rect(200, 780-mouseY, 500, 60);
  
  //A cloud
  fill(255);
  ellipse(mouseY-290, 150, 140, 80);

  //The hull of the ship
  stroke(0);
  fill(150);
  rect(200, mouseY-45, 60, 90);

  //A window on the hull of the ship
  fill(0, 185, 255);
  ellipse(200, mouseY-65, 20, 20);

  //roof of the ship
  fill(220, 0, 0);
  triangle(200, mouseY-135, 160, mouseY-90, 240, mouseY-90);

  //left fin on ship
  fill(220, 0, 0);
  triangle(170, mouseY-40, 170, mouseY, 150, mouseY);
  //centre fin on ship
  fill(220, 0, 0);
  triangle(200, mouseY-40, 190, mouseY, 210, mouseY);
  //right fin on ship
  fill(220, 0, 0);
  triangle(230, mouseY-40, 230, mouseY, 250, mouseY);
}