////  Q0.java -- CST 112 Quiz #1
//// Matthew Ruiz De Los Rios 



////////  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;




////////  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() {

   

    background(144,255,254 );            // Background should be sky-blue! 
    fill( 144,255,163 );                    // Grass should be green
    rect( 0,horizon, width,height*3/4 );

    // Flag //
    fill(255); rect(flagX,flagY, 120,90);  fill(0);
    fill(255,3,11);
    rect(490,20,40,90);
     fill(3,46,355);
    rect(400,20,40,90);
    if(mousepressed==true){
      reset();
      else
      
  
    // Target //
    fill(255,0,0); ellipse(targetX,targetY, 200,200); fill(0); 
   fill(255); ellipse(targetX,targetY, 150,150); fill(0); 
   fill(255,0,0); ellipse(targetX,targetY, 100,100); fill(0); 
   fill(255); ellipse(targetX,targetY, 50,50); fill(0);
   

  
}


////////  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 = dartDY + dartDX;
    // STOP the dart when reaches target.
    if (dartX >= targetX) {
        dartDX=0;}
        else
         {dartX=dartX+dartDX;
    }
    
    // Draw the dart, etc.

    fill(137,5,255);
    ellipse( dartX,dartY, 150,20 ); fill(0); text( "DART+++", dartX, dartY );
    triangle( dartX-30,dartY, dartX,dartY-20, dartX-50,dartY+20 );
  
    //+++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( "Matthew Ruiz De Los Rios", 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') { 
       dartDX=1;
    }
    //+++REMOVE+++//  Add your code here to handle the 't' key!  //+++REMOVE+++//
}
void mousePressed() {
if (mouseY > horizon-20);
dartX= mouseX;
dartY= mouseY;
    
}


