> show canvas only <


/* built with Studio Sketchpad: 
 *   https://sketchpad.cc
 * 
 * observe the evolution of this sketch: 
 *   https://cisc1600.sketchpad.cc/sp/pad/view/ro.vNZUHH$CAr7/rev.3073
 * 
 * authors: 
 *   Tiffany Valdez

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



//Board Dimensions
int w = 7;
int h = 6; 
int bs = 100; 
int shape = 0; 
int shapeXPos = 5; 
int shapeYPos = 4; 
int screen = 0;                        //Controls Screen

//Array for Board
int[][] board= new int[h][w];
void setup()  {
    frameRate(15); 
    size(700, 600); 
}

void draw() {
    ellipseMode(CORNER);
    rectMode (CORNER); 
    if(screen == 0) {  
        startMenu();
     }
     if (screen == 1) {
         drawBoard();
         drawShape();
         drawShape();
         drawShape();
         drawShape();
         drawShape();
    }
}
//Keyboard Function
void keyPressed() {
    if (key == ' ') {
        if (screen == 0) {
            screen = 1;
        } else {
            screen = 0;
        }
    }
}
// Broard
void drawBoard() { 
    background(random(255), random(255), random(255)); 
    for (int j = 0; j < w; j = j + 1 ) {
                        for (int i = 0; i < h; i = i + 1) {
            fill (204); 
            ellipse (j*bs, i*bs, bs, bs); 
        }
    }
  
}

//Making the shapes jump around
void drawShape() {
    ellipseMode(CENTER); 
    rectMode (CENTER); 
    if (shape == 0) {
    fill (0, 0, 255); 
            ellipse (shapeXPos*bs, shapeYPos*bs, (bs/2), (bs/2)); 
            }
    if (shape == 1) {
    fill (0, 255, 0); 
            rect (shapeXPos*bs, shapeYPos*bs,  (bs/2), (bs/2)); 
             }
    shape = shape + 1; 
    if (shape > 1) {
        shape = 0;
                }
    shapeXPos = random(7); 
    shapeYPos = random(6); 
    
//Quit Button
    rectMode (CENTER);
    fill(0);
            rect((width/7)*6,500,100,50); 
            fill(255,255,255);
            text("Quit",width/7*6,500);
    
// Back to Screen Menu
    
    if(mousePressed && mouseX>=(width/7)*6-50 && mouseX<=(width/7)*6+50 && mouseY>=500-25 && mouseY<=500+25){
        screen = 0; 
    }
}

//Start Page
void startMenu() {
    textAlign(CENTER);
  
    background(102,255,178);
    textSize(36);
    text("Tiffany's Wannabe Connect 4", width/2,100);
    fill(255,255,204);
    rectMode (CENTER);
    rect (width/2,500,300,100);
    fill(0,10,123);
    textSize(24);
    text("Click Start Now to Enter",width/2, height/2+30);
    text("---Or---",width/2, height/2);
    text("Click Spacebar to Enter/Exit",width/2, height/2-30);
    text ("Start Now", width/2,500); 
    //Function To Start
    if(mousePressed && mouseX>=(width/2)-150 && mouseX<=(width/2)+150 && mouseY>=500-50 && mouseY<=500+50) {
        screen = 1; 
    }
}