
class GameMode {

  void draw() {
  }

  void mouseClicked() {
  }

  void mouseReleased() {
  }

  void keyPressed() {
  }

  void keyReleased() {
  }
}

class Button {

  PImage buttonImage;
  int sizeX;
  int sizeY;
  int defaultSizeX;
  int defaultSizeY;
  int x;
  int y;
  int colorClicked;
  float clickTime;
  float timeButtonReady;
  Boolean buttonReady;
  Boolean clicked;
  Boolean mouseOver;
  Boolean resizable;

  int haufig = 0;

  Button(String imageName, int _x, int _y, int _sizeX, int _sizeY, Boolean _resizable) { 
    buttonImage = loadImage("assets/" + imageName);
    x = _x;
    y = _y;
    sizeX = _sizeX;
    sizeY = _sizeY;
    defaultSizeX = sizeX;
    defaultSizeY = sizeY;
    timeButtonReady = 0.2;
    buttonReady = true;
    clicked = false;
    mouseOver = false;
    clickTime = 0.0;
    resizable = _resizable;
  }

  void draw() {
    if (!buttonReady) {
      if (millis()/1000.0 - clickTime >= timeButtonReady) {
        buttonReady = true;
        clicked = false;
        sizeX = defaultSizeX;
        sizeY = defaultSizeY;
        clickTime = 0;
      }
    }
    //fill(colorClicked, 255, 0);
    //imageMode(CENTER);
    if (resizable) {
      if (clicked == true) {
        if (sizeY > defaultSizeY -10) {
          sizeX-=2;
          sizeY-=2;
        }
      } else {
        if (sizeX > defaultSizeX && sizeY > defaultSizeY) {
          sizeX+=2;
          sizeY+=2;
        }
      }
    }
    image(buttonImage, x, y, sizeX, sizeY);
    //rect(x, y, sizeX, sizeY);
  }

  void clicked() {
    if (clicked == false) {
      clicked = true;
      buttonReady = false;
      clickTime = millis()/1000.0;
    }
  }

  Boolean mouseOver(int _mouseX, int _mouseY) {
    if (_mouseX >= x && _mouseX <= x+sizeX && 
      _mouseY >= y && _mouseY <= y+sizeY && !clicked && buttonReady) {
      mouseOver = true;
      haufig++;
    } else {
      mouseOver = false;
    }
    return mouseOver;
  }
}
