Exemple #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;
  }
Exemple #2
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;
  }