import ddf.minim.*;

Minim minim;
AudioPlayer player;

int size = 1;

int xPos=100;

int yPos=0;
int yPos1=100;
int yPos2=200;
int yPos3=300;
int yPos4=400;
int yPos5=500;
int yPos6=600;



int xDir=60;

boolean button = false;

/* Try to get two buttons working simultaneously */

// Square //
/* int rectX = 25;
int rectY = 275;
int rectW = 200;
int rectH = 200; */

// Circle //
int circleX = 300;
int circleY = 300;
int circleW = 200;
int circleH = 100;

PImage bg;

void setup (){
size (600,600);
frameRate(30);

minim = new Minim(this);

player = minim.loadFile("crisis.mp3");

  
  
background(0);
bg = loadImage("magma.jpg");
}

void draw (){
  if (button) {
    
    player.play();
    
      tint(255,50);
      background (random(0,255),0,0);
      image(bg, 0, 0);
      
      noStroke();
      fill(random(255),0,10);
      //ellipse(xPos,yPos, 10, 10);
      ellipse(xPos,yPos1, 40, 40);
      //ellipse(xPos,yPos2, 60, 60);
      ellipse(xPos,yPos3, random(20,75), random(20,75));
      //ellipse(xPos,yPos4, 45, 45);
      ellipse(xPos,yPos5, 40, 40);
      //ellipse(xPos,yPos6, 10, 10);


      xPos=xPos+xDir;
  if (xPos>width-20 || xPos<20)
  {
    xDir=-xDir;
  }

  
      noStroke();
      noTint();
      fill(random(25));
      /* I hope nobody has a seizure... */
      ellipse(random(600),random(600),50,50);
      fill(random(255),0,0,random(255));
      ellipse(random(600),random(600),10,10);
      ellipse(random(600),random(600),20,20);

      fill(random(25));
      
      
  
      
      
}
  else{ 
      stroke(215);
      background(255);
      fill(230);
      
      player.pause();
      
      for (int i = 0; i < 600; i = i+15) {
  for (int j = 0; j < 600; j = j+15) {
    strokeWeight(1.5);
    point(i, j);
  }
}


}

// Circle //

ellipse(circleX,circleY,circleW,circleH);

}

// Button //

void mousePressed() {
  if (mouseX > 200 && mouseX < 400 && mouseY > 250 && mouseY < 350) {
    button = !button;
  }
}
