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; }
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; }
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; }
protected PlayField getPlayField() { return _canvas.getPlayField(); }
protected Ball getBall() { return _canvas.getBall(); }
protected void resetPlayField() { _canvas.newPlayField(); }