> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://studio.sketchpad.cc/sp/pad/view/ro.dropTkw15Np/rev.632
 * 
 * authors: 
 *   
 *   Tenzin Sherpa

 * license (unless otherwise specified): 
 *   creative commons attribution-share alike 3.0 license.
 *   https://creativecommons.org/licenses/by-sa/3.0/ 
 */ 



String mode = "initialize"; 
int firstGuess; 
int secondGuess;
int doorRevealed; 
int winningDoor; 


void setup(){
     size(400, 400); 
    
}
void draw(){
    background(0);
     
        fill(250,0,0);
         rect (25,100,100,200);
        rect (150,100,100,200);
         rect (275,100,100,200);
         textSize(25);
     fill(255,0,0);
     text("1", 75,350);
     text("2", 200,350);
     text("3",325,350);
    
    
     if(mode == "initialize"){
          firstGuess = -1; 
          secondGuess = -1; 
          doorRevealed = -1; 
          winningDoor = int(random(1, 4)); 
          mode = "firstGuess"; 
     }else if(mode == "firstGuess"){
       fill(255,0,0);
       text("Let's Make a Deal",100,25);
       text("Pick A Door",125,75);
     }else if(mode == "secondGuess"){
          while(doorRevealed == -1 || doorRevealed == winningDoor || doorRevealed == firstGuess){
               doorRevealed = int(random(1, 4));  }
          fill(255,0,0);
          text("Stay or Switch?",100,25);
          text(doorRevealed,150,75);
          text("does not have the prize!",150,75);
          if (doorRevealed==1){
            fill(0);
             rect (25,100,100,200);
          }
          else if (doorRevealed==2){
             fill(0);
             rect (150,100,100,200);
          }
          else if (doorRevealed==3){
             fill (0);
             rect (275,100,100,200);
          }
            
       
     }else if(mode == "winOrLose"){
       background(0);
            fill(255,255,0);
            textSize(40);
            text("Restart?",115,350);

          if(secondGuess==winningDoor){
            fill(0,255,0);
            textSize(50);
            text("Victory!",100,90);
          }
          if(secondGuess!=winningDoor){
            fill(255,0,0);
            textSize(50);
            text("You LOSE!",100,90);}
     }
    
     
}
void mousePressed(){
     if(mode == "firstGuess"){
          if(mouseX > 25 && mouseX < 125 && mouseY > 100 && mouseY < 300){
             mode = "secondGuess";
             firstGuess=1;
          }
          else if(mouseX > 150 && mouseX < 250 && mouseY > 100 && mouseY < 300){
             mode = "secondGuess";
             firstGuess=2;
          }
          else if(mouseX > 275 && mouseX < 375 && mouseY > 100 && mouseY < 300){
             mode = "secondGuess";
             firstGuess=3;
          }
          
     }else if(mode == "secondGuess"){
          if(doorRevealed != 1 && mouseX > 25 && mouseX < 125 && mouseY > 100 && mouseY < 300){
             mode = "winOrLose";
             secondGuess=1;
          }
          else if(doorRevealed != 2 &&mouseX >150 && mouseX < 250 && mouseY > 100 && mouseY < 300){
             mode = "winOrLose";
             secondGuess=2;
          }
          else if(doorRevealed != 3 &&mouseX > 275 && mouseX < 375 && mouseY > 100 && mouseY < 300){
             mode = "winOrLose";
             secondGuess=3;
          }
          
   
          
     }else if(mode == "winOrLose"){
           if (mouseX > 100 && mouseX < 300 && mouseY >300 && mouseY <400){mode = "initialize";
     } 
}
}