Exemplo n.º 1
0
  protected void toggleZoom(Graphics2D g) {
    _appState = Constants.appStates.Paused;

    int width = getGameOptions().get("fieldPixelWidth");
    int height = getGameOptions().get("fieldPixelHeight");

    if (width == initialOptions.fieldPixelWidth) {
      width = width * 2;
      height = height * 2;

    } else {
      width = width / 2;
      height = height / 2;
    }

    getGameOptions().put("fieldPixelWidth", width);
    getGameOptions().put("fieldPixelHeight", height);

    _canvas.setPreferredSize(
        new Dimension(
            getGameOptions().get("fieldPixelWidth"), getGameOptions().get("fieldPixelHeight")));
    _canvas.drawField(g);

    pack();
    repaint();

    _appState = Constants.appStates.Initialized;
  }
Exemplo n.º 2
0
  protected void levelWon() {
    // increase speed option
    double speedJump = 1 + (getGameOptions().get("nextLevelSpeedJump") / 100.0);

    _canvas.setCurrentMovementX(_canvas.getCurrentMovementX() * speedJump);
    _canvas.setCurrentMovementY(_canvas.getCurrentMovementY() * speedJump);

    _level++;

    resetPlayField();
    setStatus();
    repaint();
    _appState = Constants.appStates.Paused;
  }
Exemplo n.º 3
0
  protected void levelFailed(Graphics2D g) {
    try {
      InputStream in = getClass().getResourceAsStream("/sounds/fail.wav");
      m_as = new AudioStream(in);
      AudioPlayer.player.start(m_as);
    } catch (IOException e) {
    }

    _balls--;
    if (_balls == 0) {
      resetGame();
      JOptionPane.showMessageDialog(
          null, "Game Over! Your score was " + _score + " and you reached level " + _level + ".");
    } else {
      _canvas.getBall().resetPosition();
      _canvas.drawField(g);
    }
    repaint();

    _appState = Constants.appStates.Paused;
  }
Exemplo n.º 4
0
 protected PlayField getPlayField() {
   return _canvas.getPlayField();
 }
Exemplo n.º 5
0
 protected Ball getBall() {
   return _canvas.getBall();
 }
Exemplo n.º 6
0
 protected void resetPlayField() {
   _canvas.newPlayField();
 }