Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
/*****************************************************************
 By Adriana Matic
 October 20 2016
 
 Mass Effect Experience!
 See the reapers invade Earth!
 
 Click to zoom into the atmosphere and get a ground view!
 *****************************************************************/

//Variables
int allTheMeteors = 4;
int smallMeteor = 5;
int colour = 0;
float clickTest= 0;

//reaper class 
Reaper reaperScene;
Reaper reaperUpdate;

//Arrays

Meteor[] meteor = new Meteor[allTheMeteors];
Meteor[] meteors = new Meteor[smallMeteor];

/*****************************************************************
 Call update with classes
 *****************************************************************/
void makeMeteors() {
  for (int m = 0; m < meteor.length; m++) {
    meteor[m] = new Meteor(random(0, 350), random(0, 300), random(0.05, 0.5), 0.5);
  }
}
void makeSmallMeteors() {
  for (int m = 0; m < meteors.length; m++) {
    meteors[m] = new Meteor(random(0, 350), random(0, 300), random(0.01, 0.05), 0.5);
  }
}
/*****************************************************************
 Setup 
 call classes
 *****************************************************************/

void setup() {
  fill(0);
  size(400, 400);
  makeMeteors();
  makeSmallMeteors();
  reaperScene = new Reaper();
  reaperUpdate = new Reaper();
}
/*****************************************************************
 Initate all the things
 *****************************************************************/
void draw() {
  background(0);
  //make small meteors and have them fall
  //Stay behind the planet
  for (int m = 0; m<meteors.length; m++) {
    meteors[m].makeSmallMeteors();
  }
  for (int m = 0; m<meteors.length; m++) {
    meteors[m].updateMove();
  }
  earth();

  //make big meteors and have them fall
  for (int m = 0; m<meteor.length; m++) {
    meteor[m].makeMeteors();
  }
  //initate the meteors moving
  for (int m = 0; m<meteor.length; m++) {
    meteor[m].updateMove();
  }
  n7();

  /*****************************************************************
   Reaper Phase
   *****************************************************************/
  if (clickTest>=1) {
    //stop meteors and blank out
    background(192, 212, 214); 
    //initiate reaper
    reaperScene.drawReaper();
    reaperUpdate.update();

  }
}
/*****************************************************************
 Earth 
 *****************************************************************/
void earth() {

  fill(170, 247, 255, 50);
  ellipse(400, 400, 1000, 600);
  fill(92, 192, 216);
  ellipse(400, 400, 900, 500);
}

/*****************************************************************
 N7 Symbol
 *****************************************************************/
void n7() {
  //n7 symbol
  noStroke();
  fill(225, 255, 255, 220);
  rect(40, 180, 300, 120);


  fill(0);

  //N
  rect(65, 200, 20, 80);
  rect(80, 200, 20, 20);
  rect(143, 260, 20, 20);
  rect(143, 200, 20, 80);
  triangle(100, 200, 80, 210, 120, 225);
  triangle(80, 210, 120, 260, 120, 225);
  triangle(120, 225, 120, 260, 144, 260);
  triangle(120, 260, 135, 280, 144, 260);
  triangle(135, 280, 143, 260, 144, 280);
  //7
  rect(183, 200, 98, 20);
  triangle(243, 220, 280, 220, 248, 260);
  triangle(243, 220, 200, 280, 248, 260);
  triangle(248, 260, 200, 280, 233, 280);
  //red bit
  fill(255, 0, 0);
  rect(295, 200, 20, 80);
  triangle(295, 220, 250, 280, 295, 280);
}
void mouseClicked() {
  colour += 0.02; 

  print("click");
  clickTest+=1;
}
class Meteor {
  PVector position = new PVector();
  PVector velocity = new PVector();


  // float[] meteorTrailX = new float[3];
  //float[] meteorTrailY = new float[3];


  // position and velocity set for meteors
  Meteor(float x, float y, float velocityX, float velocityY) {
    position.x = x;
    position.y = y;
    velocity.x = velocityX;
    velocity.y = velocityY;
  }

  void makeMeteors() {
    //make the meteors
    fill(245, 114, 32, 50);
    ellipse(position.x, position.y, 100, 100);
    fill(216, 198, 92);
    ellipse(position.x, position.y, 80, 80);
    triangle(position.x, position.y, position.x+20, position.y +10, position.x - 20, position.y - 10);
  }

  void makeSmallMeteors() {
    //make small meteors
    fill(245, 114, 32, 50);
    ellipse(position.x, position.y, 40, 40);
    fill(216, 198, 92);
    ellipse(position.x, position.y, 20, 20);
  }
  void updateMove() {
    //move the meteors
    position.add(velocity);
    //reset position of the meteors after they fall off screen
    if (position.x > width+50) {
      position.x = 0;
      position.y = 0;
    }
    //print(velocity);
  }
}
class Reaper {


 void drawReaper() {
  //buildings
    fill(47, 65, 67);
    noStroke();
    rect(0, 120, 60, 400);
    rect(60, 160, 60, 400);
    triangle(40, 160, 80, 120, 120, 160);
    rect(100, 60, 80, 400);
    rect(220, 80, 40, 400);
    rect(260,100,20,400);
    triangle(260, 80, 260, 100, 280, 100);
    rect(280, 100, 60, 400);
    rect(320, 40, 20, 400);
    triangle(260, 100, 320, 40, 320, 100);
    rect(340, 120, 60, 400);
    rect(180,100,40,400);
      //rubble
  fill(0);
    ellipse(0,400,175,150);
    ellipse(400,400,175,150);

    fill(122,165,232,50);
    ellipse(200,400,400,200);
    fill(191,211,242,50);
    ellipse(200,400,800,200);

    
    
  
    //reaper
    fill(0);
    stroke(0);
    //upper tail
    triangle(200,20,170,125,200,145);
    triangle(200,20,225,125,200,145);
    //body
    triangle(170,125,230,160,160,160);
    triangle(225,125,230,160,200,145);
    
    rect(160,160,65,80);
    
    triangle(160,160,150,210,160,240);
    triangle(225,130,220,240,240,230);
    
    triangle(160,240,220,240,195,260);
    triangle(160,240,165,270,195,260);
    triangle(230,270,239,225,195,260);
    
    //head
    triangle(170,280,195,265,225,280);
    rect(170,280,55,20);
    triangle(180,300,180,310,195,300);
    triangle(170,300,225,300,200,310);
    
    //legs
    rect(120,220,40,10);
    //triangle(120,220,100,230,120,230);
    rect(125,240,40,10);
    rect(225,220,50,10);
    //triangle(225,220,245,230,225,220);
    rect(230,240,40,10);
    
    triangle(170,310,175,320,150,340);
    triangle(220,310,215,320,230,340);
    



  }
  void update(){
       loop();
      noStroke();
         //beam
       fill(237,0,0,100);
      triangle(180,310, 215,310, mouseX,mouseY);
  }

}