From 856eb882ba1354a836ce4cda34bfe64ff97b2414 Mon Sep 17 00:00:00 2001 From: "Raybz@Raybz" Date: Fri, 28 Jun 2013 13:22:22 +0200 Subject: [PATCH] fixed highscore refresh, tried to fix the weird shooting bug --- .../controls/PlayerShootControl.java | 16 +++++++-------- .../wyrez/shootingstars/states/GameState.java | 20 ++++++++----------- .../shootingstars/states/HighscoreState.java | 1 + 3 files changed, 17 insertions(+), 20 deletions(-) diff --git a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java index db757f0..72a0d72 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java +++ b/ShootingStars/src/org/wyrez/shootingstars/controls/PlayerShootControl.java @@ -42,7 +42,7 @@ public class PlayerShootControl extends BaseControl implements ActionListener { private GameGUI gui; private float overheatTimer = 0f; private float cooldownTimer = 0f; - private boolean wasOverheat = false; + private boolean isOverheat = false; private boolean isShooting = false; public PlayerShootControl(InputManager inputmanager, GameGUI gui) { @@ -57,10 +57,10 @@ public class PlayerShootControl extends BaseControl implements ActionListener { if (isShooting) { overheatTimer += tpf; if (overheatTimer >= MAX_TIME_TO_OVERHEAT) { + isOverheat = true; setShooting(false); overheatTimer = MAX_TIME_TO_OVERHEAT; cooldownTimer = MAX_COOLDOWN; - wasOverheat = true; } } else { if (cooldownTimer > 0f) { @@ -70,7 +70,7 @@ public class PlayerShootControl extends BaseControl implements ActionListener { overheatTimer -= tpf * COOLDOWN_FACTOR; } else { overheatTimer = 0f; - wasOverheat = false; + isOverheat = false; } } } @@ -79,10 +79,8 @@ public class PlayerShootControl extends BaseControl implements ActionListener { } private void setShooting(boolean isShooting) { - if (!(wasOverheat && overheatTimer > 0f)) { - this.isShooting = isShooting; - spatial.setUserData(UserDataKeys.SHOOTING, isShooting); - } + this.isShooting = isShooting; + spatial.setUserData(UserDataKeys.SHOOTING, isShooting); } @Override @@ -98,7 +96,9 @@ public class PlayerShootControl extends BaseControl implements ActionListener { public void onAction(String name, boolean isPressed, float tpf) { if (name.equals(MAPPING_PLAYER_MOUSE_LEFT_CLICK) && (Boolean) spatial.getUserData(UserDataKeys.RUNNING)) { - setShooting(isPressed); + if (!isOverheat) { + setShooting(isPressed); + } } } diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/GameState.java b/ShootingStars/src/org/wyrez/shootingstars/states/GameState.java index 90c2045..5b36af1 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/GameState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/GameState.java @@ -64,7 +64,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL private GameSettings settings; private AudioDataManager audioDataManager; private StarManager starManager; - private final MediaPlayerFactory mediaPlayerFactory; + private MediaPlayerFactory mediaPlayerFactory; private DirectMediaPlayer mediaPlayer; private Node rootNode; private GameGUI gui; @@ -94,14 +94,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL this.viewPort = viewPort; this.optionSettings = optionSettings; this.highscoreManager = highscoreManager; - - if (settings.useVideo() || !optionSettings.isAudioVisualizationEnabled()) { - mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet"); - } else { - mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet", - "--audio-visual=visual", "--effect-list=scope"); - } - this.settings = settings; Particles.setParticleDensity(optionSettings.getParticleDensity()); @@ -115,7 +107,12 @@ public class GameState extends AbstractAppState implements GameListener, ActionL } public void initMediaPlayer() throws Exception { - System.out.println("create"); + if (settings.useVideo() || !optionSettings.isAudioVisualizationEnabled()) { + mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet"); + } else { + mediaPlayerFactory = new MediaPlayerFactory("--no-video-title-show", "--quiet", + "--audio-visual=visual", "--effect-list=scope"); + } mediaPlayer = mediaPlayerFactory.newDirectMediaPlayer(settings.getVideoFormat(), settings.getVideoWidth(), settings.getVideoHeight(), settings.getVideoWidth() * settings.getVideoDepth(), cinema); @@ -176,8 +173,6 @@ public class GameState extends AbstractAppState implements GameListener, ActionL rootNode.detachChild(player); rootNode.detachChild(ground); rootNode.detachChild(cinema); - mediaPlayer.release(); - mediaPlayerFactory.release(); inputManager.setCursorVisible(true); } @@ -204,6 +199,7 @@ public class GameState extends AbstractAppState implements GameListener, ActionL mediaPlayer.release(); mediaPlayerFactory.release(); mediaPlayer = null; + mediaPlayerFactory = null; player = null; ground = null; cinema = null; diff --git a/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java b/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java index cd843e8..42653db 100644 --- a/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java +++ b/ShootingStars/src/org/wyrez/shootingstars/states/HighscoreState.java @@ -51,6 +51,7 @@ public class HighscoreState extends AbstractAppState implements HighscoreListene @Override public void stateAttached(AppStateManager stateManager) { + gui.refresh(); gui.attach(); music.play(); }