Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/* Tristan Peskett
move your jet across the screen as you fly over islands and oceans
click mouse to fire lazer
hold space for thruster boost
*/
void setup() {
  //define window size
  size(400, 400);
 //set to 30fps
  frameRate(30);
  noCursor();
}

void draw() {
  background(80, 157, 182);

  rectMode(CENTER);

  //background waves


  noFill();
  stroke(255, 255, 255, 90);
  strokeWeight(6);
  rect(200, -309+(frameCount*1 % 1000), 500, 400);
  ellipse(100, -169+(frameCount*1 % 1000), 400, 200);
  ellipse(30, -149+(frameCount*1 % 1000), 400, 200);
  ellipse(400, -149+(frameCount*1 % 1000), 140, 200);
  ellipse(360, -179+(frameCount*1 % 1000), 140, 200);
  ellipse(200, -482+(frameCount*1 % 1000), 600, 200);
  strokeWeight(2);
  ellipse(200, -490+(frameCount*1 % 1000), 600, 200);
  
  // island waves
  noFill();
  stroke(255, 255, 255, 90);
  strokeWeight(6);
  ellipse(40,-800+(frameCount*1 % 2000), 110,140);


  //background sand
  noStroke();
  fill(220, 220, 185);
  rect(200, -310+(frameCount*1 % 1000), 500, 400);
  ellipse(100, -170+(frameCount*1 % 1000), 400, 200);
  ellipse(30, -150+(frameCount*1 % 1000), 400, 200);
  ellipse(400, -150+(frameCount*1 % 1000), 140, 200);
  ellipse(360, -180+(frameCount*1 % 1000), 140, 200);
  ellipse(200, -480+(frameCount*1 % 1000), 600, 200);

//island sand
noStroke();
  fill(220, 220, 185);
  ellipse(40,-800+(frameCount*1 % 2000), 108,138);

  //background grass
  noStroke();
  fill(100, 163, 122);
  rect(200, -330+(frameCount*1 % 1000), 500, 400);
  ellipse(100, -180+(frameCount*1 % 1000), 400, 200);
  ellipse(30, -160+(frameCount*1 % 1000), 400, 200);
  ellipse(400, -160+(frameCount*1 % 1000), 140, 200);
  ellipse(360, -190+(frameCount*1 % 1000), 140, 200);
  ellipse(200, -470+(frameCount*1 % 1000), 600, 200);
  
  //island grass
   noStroke();
  fill(46, 162, 117,180);
  ellipse(40,-800+(frameCount*1 % 2000), 90,120);


  //building
  noStroke();
  fill(50, 50, 50, 100);//1
  rect(200, -190+(frameCount*1 % 1000), 40, 30);
  fill(117);
  rect(210, -200+(frameCount*1 % 1000), 40, 30);
  fill(81);
  rect(210, -200+(frameCount*1 % 1000), 35, 25);

  fill(50, 50, 50, 100);//2
  rect(280, -220+(frameCount*1 % 1000), 80, 40);
  fill(117);
  rect(290, -230+(frameCount*1 % 1000), 80, 40);
  fill(81);
  rect(290, -230+(frameCount*1 % 1000), 75, 35);

  fill(50, 50, 50, 100);//3
  rect(280+100, -120-300+(frameCount*1 % 1000), 80, 40);
  fill(117);
  rect(290+100, -130-300+(frameCount*1 % 1000), 80, 40);
  fill(81);
  rect(290+100, -130-300+(frameCount*1 % 1000), 75, 35);


  //trees
  fill(50, 50, 50, 90);//1
  ellipse(148+25, -398+25+(frameCount*1 % 1000), 25, 25);
  fill(43, 104, 40);
  ellipse(152+25, -402+25+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154+25, -404+25+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154+25, -404+25+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//2
  ellipse(148, -398+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152, -402+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154, -404+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154, -404+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//3
  ellipse(148+40, -398+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152+40, -402+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154+40, -404+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154+40, -404+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//4
  ellipse(148-30, -198+25+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152-30, -202+25+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154-30, -204+25+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154-30, -204+25+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//5
  ellipse(148-55, -198-20+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152-55, -202-20+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154-55, -204-20+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154-55, -204-20+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//6
  ellipse(148-15, -198+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152-15, -202+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154-15, -204+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154-15, -204+(frameCount*1 % 1000), 16, 16);

  fill(50, 50, 50, 90);//7
  ellipse(148-95, -138+(frameCount*1 % 1000), 25, 25);
  fill(42, 111, 39);
  ellipse(152-95, -142+(frameCount*1 % 1000), 25, 25);
  fill(62, 141, 49);
  ellipse(154-95, -144+(frameCount*1 % 1000), 20, 20);
  fill(92, 161, 69);
  ellipse(154-95, -144+(frameCount*1 % 1000), 16, 16);
  
  //sail boats
   
  noStroke();
   fill(108,108,128,90);
  ellipse(-803+(frameCount*1 % 2000), -987+(frameCount*1 % 2000), 17,8);//shadow
    stroke(220,220,220,90);
   strokeWeight(2);
   line(-800+(frameCount*1 % 2000), -990+(frameCount*1 % 2000),-815+(frameCount*1 % 2000)+cos(millis()/40)*1, -991+(frameCount*1 % 2000));//water splash
    stroke(220,220,220,150);
   line(-800+(frameCount*1 % 2000), -988+(frameCount*1 % 2000),-815+(frameCount*1 % 2000)+cos(millis()/40)*1, -988+(frameCount*1 % 2000));//2
   noStroke();
  fill(187,188,188);
  ellipse(-800+(frameCount*1 % 2000), -990+(frameCount*1 % 2000), 15,8);//boat base
  fill(220,220,220);
  triangle(-803+(frameCount*1 % 2000),-997+(frameCount*1 % 2000),-789+(frameCount*1 % 2000),-990+(frameCount*1 % 2000),-803+(frameCount*1 % 2000),-990+(frameCount*1 % 2000));//sail

   
  //birds
  stroke(255);
  strokeWeight(2);
  line(80-10, -120+(frameCount*1.8 % 1000), 72-10, -120+(frameCount*1.8 % 1000));//1
  line(76.8-10, -121.5+(frameCount*1.8 % 1000), 76.8-10, -117+(frameCount*1.8 % 1000));
  line(75-10, -116+(frameCount*1.8 % 1000), 77-10, -116+(frameCount*1.8 % 1000));
  
  line(80+30, -120+(frameCount*1.8 % 1000), 72+30, -120+(frameCount*1.8 % 1000));//2
  line(76.8+30, -121.5+(frameCount*1.8 % 1000), 76.8+30, -117+(frameCount*1.8 % 1000));
  line(75+30, -116+(frameCount*1.8 % 1000), 77+30, -116+(frameCount*1.8 % 1000));

  line(80+10, -120-20+(frameCount*1.8 % 1000), 72+10, -120-20+(frameCount*1.8 % 1000));//3
  line(76.8+10, -121.5-20+(frameCount*1.8 % 1000), 76.8+10, -117-20+(frameCount*1.8 % 1000));
  line(75+10, -116-20+(frameCount*1.8 % 1000), 77+10, -116-20+(frameCount*1.8 % 1000));
  
  line(80-30, -120+20+(frameCount*1.8 % 1000), 72-30, -120+20+(frameCount*1.8 % 1000));//4
  line(76.8-30, -121.5+20+(frameCount*1.8 % 1000), 76.8-30, -117+20+(frameCount*1.8 % 1000));
  line(75-30, -116+20+(frameCount*1.8 % 1000), 77-30, -116+20+(frameCount*1.8 % 1000));
  
  line(80+50, -120+20+(frameCount*1.8 % 1000), 72+50, -120+20+(frameCount*1.8 % 1000));//5
  line(76.8+50, -121.5+20+(frameCount*1.8 % 1000), 76.8+50, -117+20+(frameCount*1.8 % 1000));
  line(75+50, -116+20+(frameCount*1.8 % 1000), 77+50, -116+20+(frameCount*1.8 % 1000));

  //ship shadow w/t parralax effect
  noStroke();
  fill(80, 80, 80, 50);
  ellipse(mouseX/2+100, mouseY+40, 10, 20);

  //cloud shadow
  noStroke();
  fill(50, 50, 50, 20);
  ellipse(181-47, -50+-10+ (frameCount*12 % 1000), 80, 120);//1
  fill(50, 50, 50, 80);
  ellipse(390-60, -150+-97+ (frameCount*7 % 1000), 210, 350);//2
  fill(50, 50, 50, 80);
  ellipse(90-100, -279+60+ (frameCount*3 % 1000), 220, 350);//3



  //clouds
  noStroke();
  fill(210, 220, 255);//1
  ellipse(170, -238+ (frameCount*12 % 1000), 80, 100);
  ellipse(190, -192+ (frameCount*12 % 1000), 80, 100);
  ellipse(130, -185+ (frameCount*12 % 1000), 80, 100);

  noStroke();
  fill(210, 220, 255);//2
  ellipse(340, -496+ (frameCount*7 % 1000), 100, 160);
  ellipse(320, -414+ (frameCount*7 % 1000), 100, 150);
  ellipse(399, -467+ (frameCount*7 % 1000), 100, 150);
  ellipse(390, -292+ (frameCount*7 % 1000), 190, 350);

//3
  ellipse(40, -482+ (frameCount*3 % 1000), 100+20, 160);
  ellipse(70, -528+ (frameCount*3 % 1000), 100+20, 150);
  ellipse(99, -492+ (frameCount*3 % 1000), 100+20, 150);
  ellipse(90, -330+ (frameCount*3 % 1000), 190+50, 350);
  
  //jetstream
  strokeCap(ROUND);
  stroke(180, 180, 180,80);
  strokeWeight(25);
  line(mouseX, mouseY, mouseX, mouseY+cos(millis()/80)*8+ 350);//pale smoke

  stroke(255, 150, 20);
  strokeWeight(15);
  line(mouseX, mouseY, mouseX, pmouseY-2.5 +cos(millis()/50)*10+ 170);//large orange

  stroke(255, 200, 20);
  strokeWeight(10);
  line(mouseX, mouseY, mouseX, pmouseY-5 +cos(millis()/20)*6+ 135);//smaller orange

  stroke(255, 250, 100);
  strokeWeight(5);
  line(mouseX, mouseY, mouseX, pmouseY-5 +cos(millis()/10)*3+ 110);//small yellow

  //engine
  strokeWeight(1);
  stroke(130);
  fill(130, 130, 130);
  rect(mouseX, mouseY, 40, 25);

  strokeWeight(1);
  stroke(60);
  fill(50);
  rect(mouseX, mouseY, 20, 25);

  //ship body
  noStroke();
  fill(40);
  rect(mouseX-10, mouseY-70, 2.5, 15);//gun
  rect(mouseX+10, mouseY-70, 2.5, 15);//2
  triangle(mouseX, mouseY-70, mouseX-70, mouseY, mouseX+70, mouseY);//large wings
  fill(50);
  triangle(mouseX, mouseY-100, mouseX-35, mouseY, mouseX+35, mouseY);//smaller wings
  fill(60);
  triangle(mouseX, mouseY-125, mouseX-12.5, mouseY, mouseX+12.5, mouseY);//nose and body
  fill(150);
  noStroke();
  ellipse(mouseX, mouseY-50, 10, 30);//cockpit
  fill(220);
  noStroke();
  ellipse(mouseX+1.5, mouseY-50, 2.5, 20);//cockpit highlight

  //jet
  stroke(255, 140, 0);
  fill(255, 140, 0);
  triangle(mouseX+27.5, mouseY+cos(millis()/18)*6+17.5, mouseX+32.5, mouseY, mouseX+22.5, mouseY);//left booster orange
  stroke(255, 200, 110);
  fill(255, 200, 110);
  triangle(mouseX+27.5, mouseY+cos(millis()/20)*6+6, mouseX+31.5, mouseY, mouseX+23.5, mouseY);//left booster yellow
  stroke(255, 140, 0);
  fill(255, 140, 0);
  triangle(mouseX-27.5, mouseY+cos(millis()/18)*6+17.5, mouseX-32.5, mouseY, mouseX-22.5, mouseY);//right booster orange
  stroke(255, 200, 110);
  fill(255, 200, 110);
  triangle(mouseX-27.5, mouseY+cos(millis()/20)*6+6, mouseX-31.5, mouseY, mouseX-23.5, mouseY);//right booster yellow

  //cloud above
  noStroke();
  fill(250, 250, 250, 180);
  ellipse(40, -482+ (frameCount*3 % 1000), 100+20, 160);
  ellipse(70, -528+ (frameCount*3 % 1000), 100+20, 150);
  ellipse(99, -492+ (frameCount*3 % 1000), 100+20, 150);
  ellipse(90, -330+ (frameCount*3 % 1000), 190+50, 350);
}
void mousePressed() { 
  //laser
  //background(150, 130, 200);
  fill(250, 200, 50);
  rect(mouseX+10, mouseY-305, 1.5, 450);//lazer
  rect(mouseX-10, mouseY-305, 1.5, 450);//2
  noStroke();
  fill(255, 255, 255, 80);
  ellipse(mouseX+10, mouseY-80, 18, 14);//muzzle flash
  ellipse(mouseX-10, mouseY-80, 18, 14);//2

  strokeWeight(2);
  stroke(230, 230, 40);
  fill(255);
  ellipse(mouseX+10, mouseY-80, 9, 7);//3
  ellipse(mouseX-10, mouseY-80, 9, 7);//4
}

void keyPressed() {
  //ultra boost
  strokeCap(SQUARE);
  stroke(255, 0, 0, 150);
  strokeWeight(30);
  fill(255);
  line(mouseX, mouseY+12, mouseX, mouseY+400);
  strokeWeight(10);
  fill(255);//red booster
  line(pmouseX-15, pmouseY+12, pmouseX, pmouseY+400);
  line(pmouseX+15, pmouseY+12, pmouseX, pmouseY+400);
  line(pmouseX-28, pmouseY-1, pmouseX-28, pmouseY+400);
  line(pmouseX+27, pmouseY-1, pmouseX+28, pmouseY+400);
  strokeWeight(4);
  stroke(255, 255, 255, 20);
  line(pmouseX-65, pmouseY-1, pmouseX-65, pmouseY+400);
  line(pmouseX+65, pmouseY-1, pmouseX+65, pmouseY+400);
  
   
}