////  Q0.java -- CST 112 Quiz #1
////  Chandni Ochani

//+++REMOVE+++//  Modify code as needed, and REMOVE ALL +++ instructions!  //+++REMOVE+++//


////////  GLOBAL DECLARATIONS  //////// 
String help=  "click below horizon to set the dart\n"
  + "click flag (or 'd' key) to throw.\n"
  + "r resets dart & target, q to quit.";

float horizon;
float flagX, flagY;                  // Coordinates of flag
float targetX, targetY;              // Coordinates of the bullseye.
float dartX, dartY, dartDX, dartDY;  // Coordinates & velocity for dart.
int score=0;

//+++REMOVE+++//  Add more declarations here, as needed.    //+++REMOVE+++//


////////  SETUP //////// 
void setup() {
  size(800, 600);
  flagX=width/2;
  flagY=20;
  reset();
}
void reset() {
    horizon=  height / 4;
    targetX=  width-120;
    targetY=  random( horizon, height-100 );
    dartDX=dartDY=0;
    dartX=  100;
    dartY=  random( horizon, height-100 );

    //+++REMOVE+++//  Modify any of this code as needed!       //+++REMOVE+++//
    //+++REMOVE+++//  Add more declarations here, as needed.   //+++REMOVE+++//

}

////////  NEXT FRAME //////// 
void draw() {
    scene();
    action();
    messages();
}


////////  Draw the scene //////// 
void scene() {

    //+++REMOVE+++//  Modify this code to draw the scene:  grass, etc.  //+++REMOVE+++//

    background( 0,0,255); 
    fill( 0,255,0);
    rect( 0,horizon, width,height*3/4 );
   
    // Flag // 
    fill(0,255,255); rect (flagX,flagY,30,100);
    fill(255,255,0); rect (flagX+30,flagY,30,100);
    fill(255); rect(flagX-50, flagY,40,100);
    
}
   
////////  ACTION:
////////    * Move the dart (until it stops), update score, etc.
////////    * Draw everything on the screen
void action() {

    //+++REMOVE+++//  Add YOUR code below, to move & draw the objects.  //+++REMOVE+++//

 // Move the dart
    dartX = dartX + dartDX;
    // STOP the dart when reaches target.
    if (dartX >= targetX) {
        dartDX=0;
        //+++REMOVE+++//  Add your code here, to update score, etc.     //+++REMOVE+++//
    }
    
    // Draw the dart, etc.

    fill(0,200,0); ellipse( dartX,dartY, 80,20 ); fill(0); text( "DART+++", dartX, dartY );
    //+++REMOVE+++//  +++ REPLACE the above with YOUR code to draw dart.   //+++REMOVE+++//

}

//////// MESSAGES:  title, author, score, etc. //////// 
void messages() {
    fill(0);
    textSize(24);
    text( "CST 112 Quiz #1", 10, 20 );
    text( "SCORE:", width*3/4,20 );
    textSize(12);
    text( help, 20,50 );
    text( "Chandni Ochani", 10, height-10 );
  
    //+++REMOVE+++//  Add your code, to display score on the screen.  //+++REMOVE+++//

}

  
//////// EVENT HANDLERS:  keys & mouse ////////
void keyPressed() {
    if (key == 'q') { exit(); }
    if (key == 'r') { reset(); }

    if (key == 'd') { 
        //+++REMOVE+++//  Add your code here, to handle the 'd' key!  //+++REMOVE+++//
    }
    //+++REMOVE+++//  Add your code here to handle the 't' key!  //+++REMOVE+++//
}
void mousePressed() {

    //+++REMOVE+++//  Add your code to handle mouse clicks on the flag!  //+++REMOVE+++//

    //+++REMOVE+++//  Add your code to handle clicks below the horizon!  //+++REMOVE+++//

}


//+++REMOVE+++//  PLEASE REMOVE ALL +++ LINES BEFORE SUBMITTING YOUR CODE!  //+++REMOVE+++//


