Example #1
0
  public void update() {
    if (!grid.isPaused()) {
      grid.update();
    }

    score = grid.getScore();
    if (score >= highScore) {
      highScore = score;
    }

    if (grid.isGameOver()) {
      hasFlushed = true;
    } else if (!grid.isGameOver() && hasFlushed) {
      hasFlushed = false;
    }

    if (Gdx.input.justTouched()
        && ScreenManager.getCurrentScreen()
            .inputManager
            .getIntersecting(restartButton.getHitbox())) {
      if (grid.isGameOver()) {
        grid.restart();
        saveState();
      }
    }

    if (Gdx.input.justTouched() && grid.isPaused()) {
      if (ScreenManager.getCurrentScreen().inputManager.getIntersecting(menuButton.getHitbox())) {
        grid.newRound();
        grid.endRound();
        grid.setPaused(false);
        saveState();
        ScreenManager.setScreen(new TitleScreen(title));

      } else if (ScreenManager.getCurrentScreen()
          .inputManager
          .getIntersecting(unpauseButton.getHitbox())) {
        grid.setPaused(false);
      } else if (ScreenManager.getCurrentScreen()
          .inputManager
          .getIntersecting(restartButton.getHitbox())) {
        grid.restart();
        grid.setPaused(false);
        saveState();
      }
    }
    handleAds();
  }
Example #2
0
  public void render(SpriteBatch sb) {
    grid.render(sb);
    redCounter.draw(sb);
    blueCounter.draw(sb);
    scoreCounter(sb);
    highScoreCounter(sb);
    if (grid.isGameOver()) {
      backGroundFade.draw(sb);
      gameOverOverlay.draw(sb);
      restartButton.render(sb);
    }

    if (grid.isPaused()) {
      backGroundFade.draw(sb);
      menuButton.render(sb);
      restartButton.render(sb);
      unpauseButton.render(sb);
    }
  }