Exemplo n.º 1
0
  public void draw() {
    switch (gameState) {
      case START:
        background(0);
        break;
      case PLAY:
        background(100);
        sun.display();
        sun.update();

        garden.display();
        garden.update();

        milk.update();
        milk.display();

        textSize(20);
        text("Sun : " + sunGrade, 10, 20);

        // Sun collision test
        if (isHit(sun.x, sun.y, sun.w, sun.h, mouseX, mouseY, 0, 0)) {
          sun.getEaten();
          sunGrade += 50;
        }

        // Bullet collision test

        break;
      case WIN:
        break;
      case LOSE:
        break;
    }
  }
Exemplo n.º 2
0
 public void mouseReleased() {
   if (fruitOption == Banana && sunGrade >= BananCost) {
     sunGrade -= BananCost;
   } else if (fruitOption == Melon) {
     sunGrade -= BananCost;
   } else return;
   garden.addPlant(fruitOption, mouseX, mouseY);
 }