Your browser does not support the canvas tag.

previous        Show / Hide Source        Download        next
// Xenoblade Chronicles 2
// By: Mya Cordner-Cassidy
// Assisted by Nathan Arcari
// Become the master driver by unlocking the legendary Aegis Core Crystal
// Change the core crystal by filling up the party gauge in the top left corner, do this by clicking the screen when the gold circle is on top of the middle circle.




//variables
//colours
int r = 58;
int g = 197;
int b = 232;
int m = 34;
int y = 136;
int a = 164;
int l = 80;
int k = 200;
int d = 120;
int t = 0;
int p = 57;
int j = 184;
int e = 9;
int s = 9;
int z = 68;


float speed = 1;
float ro = 320;

float ringSpeed = 2;
float rr = 600;

int score = 0;
int image = 1;

void setup() {
  size(400, 400);

  frameRate(60);
}

//Background
void draw() {
  background(9, 9, 68);
  fill(9, 9, 68);
  rect(0, 0, 400, 400);

  // party gauge bar:
  noStroke();
  fill(t, p, j);
  rectMode(CENTER);
  rect(100, 20, 200, 20);

  //party gauge:
  stroke(255, 215, 0);
  noFill();
  ellipseMode(CENTER);
  ellipse(40, 20, 40, 10);
  ellipseMode(CENTER);
  ellipse(100, 20, 40, 10);
  ellipseMode(CENTER);
  ellipse(160, 20, 40, 10);

  // Moving ring:
  stroke(255, 215, 0);
  noFill();
  ellipseMode(CENTER);
  ellipse(200, 200, rr, rr);
  rr = rr - ringSpeed;
  if (ro > 600 || ro < 240) {
    ringSpeed = ringSpeed *-2;
  }

  //Updating the score
  if (score>=1) {
    noStroke();
    fill(255, 215, 0);
    ellipseMode(CENTER);
    ellipse(40, 20, 40, 10);
  }
  if (score>=2) {
    noStroke();
    fill(255, 215, 0);
    ellipseMode(CENTER);
    ellipse(100, 20, 40, 10);
  }
  if (score>=3) {
    noStroke();
    fill(255, 215, 0);
    ellipseMode(CENTER);
    ellipse(160, 20, 40, 10);
  }

  //updating core crystals
  if (image == 1) {
    commonCoreCrystal();
  }

  if (image == 2) {
    aegisCoreCrystal();
  }
  if (image>2) {
    image = 1;
  }

  if (score>3) {
    score = 0;
    image++;
  }
}


//Filling in the party gauge circles
void mousePressed() {
  if (rr<= 240) {
    score ++;
    rr = random(500, 800);
  }
}



void commonCoreCrystal() {
  //inner circle:
  noStroke();
  fill(r, g, b, 40);
  ellipseMode(CENTER);
  ellipse(width/2, height/2, 240, 240);

  //outer circle
  noStroke();
  fill(r, g, b, 40);
  ellipseMode(CENTER);
  ellipse(width/2, height/2, ro, ro);
  ro = ro + speed;
  if (ro > 360 || ro < 320) {
    speed = speed *-1;
  }


  //first layer of common core crystal:
  noStroke();
  fill(m, y, a);
  rectMode(CENTER);
  rect(200, 200, 160, 20);

  noStroke();
  fill(m, y, a);
  triangle(190, 120, 120, 190, 220, 190);
  triangle(210, 120, 280, 190, 170, 190);

  noStroke();
  fill(m, y, a);
  triangle(190, 280, 120, 210, 220, 210);
  triangle(210, 280, 280, 210, 180, 210);

  //second layer of common core crystal:
  noStroke();
  fill(r, g, b);
  triangle(200, 120, 120, 200, 280, 200);
  triangle(200, 280, 120, 200, 280, 200);

  //third layer of common core crystal:
  noStroke();
  fill(m, y, a);
  triangle(140, 180, 120, 200, 160, 200);
  triangle(140, 220, 120, 200, 160, 200);

  noStroke();
  fill(31, 145, 176);
  triangle(260, 180, 240, 200, 280, 200);
  triangle(260, 220, 240, 200, 280, 200);

  //fourth layer of common core crystal:
  //left circle
  noStroke();
  fill(23, 115, 140);
  ellipseMode(CENTER);
  ellipse(160, 200, 40, 40);

  //left lines
  stroke(m, y, a);
  line(140, 180, 160, 200);
  stroke(31, 145, 176);
  line(160, 200, 140, 220);

  //right circle
  noStroke();
  fill(23, 115, 140);
  ellipseMode(CENTER);
  ellipse(240, 200, 40, 40);

  //right lines
  stroke(m, y, a);
  line(260, 180, 240, 200);
  stroke(31, 145, 176);
  line(240, 200, 260, 220);

  //fifth layer of common core crystal:
  noStroke();
  fill(r, g, b);
  rectMode(CENTER);
  rect(200, 200, 80, 40);

  //left side
  noStroke();
  fill(r, g, b);
  triangle(140, 180, 160, 180, 160, 200);
  triangle(140, 220, 160, 220, 160, 200);

  //right side
  noStroke();
  fill(r, g, b);
  triangle(260, 180, 240, 180, 240, 200);
  triangle(260, 220, 240, 220, 240, 200);
}

float speed2 = 1;
float ro2 = 320;

void aegisCoreCrystal() {

  //inner circle:
  noStroke();
  fill(l, k, d, 40);
  ellipseMode(CENTER);
  ellipse(width/2, height/2, 240, 240);

  //outer circle
  noStroke();
  fill(l, k, d, 40);
  ellipseMode(CENTER);
  ellipse(width/2, height/2, ro2, ro2);
  ro2 = ro2 + speed2;
  if (ro2 > 360 || ro2 < 320) {
    speed2 = speed2 *-1;
  }

  //first layer of Aegis core crystal:
  noStroke();
  fill(l, k, d);
  rectMode(CENTER);
  rect(200, 200, 80, 210);

  noStroke();
  fill(l, k, d);
  rectMode(CENTER);
  rect(200, 190, 120, 60);

  //second layer of Aegis core crystal:
  noStroke();
  fill(l, k, d);
  rectMode(CENTER);
  rect(200, 110, 40, 20);

  noStroke();
  fill(l, k, d);
  rectMode(CENTER);
  rect(130, 190, 20, 20);

  noStroke();
  fill(l, k, d);
  triangle(140, 160, 120, 180, 140, 180);
  triangle(140, 200, 120, 200, 140, 220);

  noStroke();
  fill(l, k, d);
  rectMode(CENTER);
  rect(270, 190, 20, 20);

  noStroke();
  fill(l, k, d);
  triangle(260, 160, 280, 180, 260, 180);
  triangle(280, 200, 260, 200, 260, 220);
}