Example #1
0
  public boolean updateState(Landscape scape) {
    // this method has an added on season change every 1/4 minute

    // first 1/4 minute:
    if ((System.currentTimeMillis() / 15000) % 2 == 0) {
      if ((this.y > scape.getHeight() / 2)
          && (this.x > scape.getWidth() / 2)) { // if this is in the southeast ish
        if (quantity < MAX_QUANTITY) {
          quantity += 2; // grow by 2
        }
      } else { // else grow by 1 each time
        if (quantity < MAX_QUANTITY) {
          quantity++;
        }
      }
    }

    // second 1/4 minute:
    else if ((System.currentTimeMillis() / 15000) % 2 != 0) {
      if ((this.y < (scape.getHeight() / 2))
          && (this.x < scape.getWidth() / 2)) { // if this is in the northwest ish
        if (quantity < MAX_QUANTITY) {
          quantity += 2; // grows by 2
        }
      } else { // else grow by 1 each time
        if (quantity < MAX_QUANTITY) {
          quantity++;
        }
      }
    }

    // System.out.print(this.quantity+",");
    return true; // it can be assumed that this always returns true since peas never die
  }