void menu () {
        image(menuBg, width/2, height/2);
        ScrollText();
        image(menuBgMk, width/2, height/2);
        renderStarField();
        menuTitlePic.display();

    if (mouseOver.pic(menuTitlePic)) {
          menuTitlePic2.display();

          if (clickOnce) {
            menuOn = false;
            menuInfoOn = true;
            clickOnce = false;
            click.play();
          }
    } else { menuTitlePic.display();  }

    if (mouseOver.pic(menuLogoPic)) { 
      menuLogoPic2.display();
      if (clickOnce) { 
                goToLink(); 
                clickOnce = false;
                click.play();
              }
    } else { menuLogoPic.display();  }
    
     invSeqASprite.x = 700;
     invSeqBSprite.x = invSeqASprite.x+50;
     invSeqCSprite.x = invSeqBSprite.x+50;
     invSeqASprite.loop(); invSeqASprite.update(); invSeqASprite.draw();
     invSeqBSprite.loop(); invSeqBSprite.update(); invSeqBSprite.draw();
     invSeqCSprite.loop(); invSeqCSprite.update(); invSeqCSprite.draw();
}



void menuInfo() {
    image(menuInfo, width/2, height/2);

    if (mouseOver.rectan(575, 280, 200, 40)) {       /////// PRINCIPIANTE BUTTON
          fill(128,100,128);
          if (clickOnce) {
              restart();
              avanzado = false;
              menuInfoOn = false;
              clickOnce = false;
              limitShoot = 3;
              invadersSpeed = 1.13;
              click.play();
          }
    } else { fill(128,0,128); }
    
    rect(575, 280, 200, 40);
        
    if (mouseOver.rectan(575, 325, 200, 40)) {        /////// EXPERTO BUTTON
        fill(128,100,128);
        if (clickOnce) {
            restart();
            avanzado = true;
            menuInfoOn = false;
            clickOnce = false;
            limitShoot = 1;
            invadersSpeed = 1.18;
            click.play();
        }
    } else { fill(128,0,128);  }
    
    rect(575, 325, 200, 40);
    fill(255);
    textSize(18);
    text("Principiante", 575, 288);
    text("Avanzado", 575, 332);
}

void infoGame() {
    fill(255);
    textFont(myFont);
    textSize(16);
    text("<PUNTOS: " + dead + ">" , 95, 30);
    text("<TIEMPO: " + elapsed + ">" , 395, 30);
    if (avanzado) { text("Avanzado", 650, 30); } else { text("Principiante", 650, 30); }
    text("<CREDITO: " + credit + ">" , 850, 30);
    
    fill(210,105,30);
    //refugioPic.display();
    //rect(0,height-5, width,20);
    
    // fill(0,110,255,120); ///////// MARCO BALUARTE
    // rect(884,527, 110,15);
    // textSize(10); /////////BALUARTE COPYRIGHT
    // fill(255,255,255);
    // text("© Baluarte 2018" , 836, 532);
}
  


public class Picture {
    float x, y;
    float w, h;
    PImage pic;
    
    Picture(PImage pic, float x, float y) {
        this(pic, x, y, pic.width, pic.height); 
    }
  
    Picture(PImage pic, float x, float y, float w, float h) {
        this.x = x;
        this.y = y;
        this.pic = pic;
        this.w = w; 
        this.h = h;
    }

    void display() {
        image(this.pic, this.x, this.y, this.w, this.h);
    }
}


class MouseOver {
    float x;
    float xx;
    float y;
    float yy;

    boolean rectan(float cx, float cy, float cw, float ch) {
        this.x = cx - cw/2;
        this.xx = cx + cw/2;
        this.y = cy - ch/2;
        this.yy = cy + ch/2;
    
        if ((mouseX > this.x && mouseX < this.xx && mouseY > this.y && mouseY < this.yy)) {
            // if (roll) { playSound(rollOver); roll = false; }
            return true;
        } else {  return false; }
    }
    
    boolean pic(Picture img) {
          
          this.x = img.x - img.w/2;
          this.xx = img.x + img.w/2;
          this.y = img.y - img.h/2;
          this.yy = img.y + img.h/2;
        
          if ((mouseX > this.x && mouseX < this.xx && mouseY > this.y && mouseY < this.yy)) {
              return true;
          }  else { return false; }
    }
}



void mousePressed() {
    clickOnce = true;
    //console.log("clickOnce: " + clickOnce  );
}


void mouseReleased() {
    clickOnce = false;
    //console.log("clickOnce: " + clickOnce );
}

void goToLink() {
  link("https://www.argentina.gob.ar/agroindustria"); 
}
