diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gameplay/SongPlayer.java | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/src/gameplay/SongPlayer.java b/src/gameplay/SongPlayer.java index 3e465bd..13b2b72 100644 --- a/src/gameplay/SongPlayer.java +++ b/src/gameplay/SongPlayer.java @@ -44,6 +44,9 @@ public class SongPlayer extends Pane { private Double bpm; //initializes the bpm of the song, to be read in from a metadata file later private int songLength; //initializes the length of the song in terms of the song's bpm, to be read in later + private File song; + private boolean songIsPlaying = false; + private main.Level level; private Difficulty difficulty; private Pane pane; @@ -107,8 +110,8 @@ public class SongPlayer extends Pane { } public SongPlayer(main.Level lvl, Difficulty d, Pane p, ScoreController cntrl) { - - Driver.soundController.playSong(lvl.song); + Driver.soundController.endSong(); + song = lvl.song; if (lvl.background != null) { Driver.setBackground(lvl.background.getUrl()); @@ -162,6 +165,9 @@ public class SongPlayer extends Pane { if (e.getCode() == KeyCode.K) { checkNote(kLane, kButton); } + if (e.getCode() == KeyCode.Q) { + System.out.println("" + timer.time()); + } //prints the user's current score and combo, for debugging purposes //System.out.println("Score: " + scoreCounter.getScore() + "\nCombo: " + scoreCounter.getCombo() + "\n"); }); @@ -252,7 +258,9 @@ public class SongPlayer extends Pane { gui.Driver.setMenu(new GameOver(level, difficulty, pane, scoreCounter.getScore())); cancel(); } - if (timer.time() > 0.0) { + if (!songIsPlaying && timer.time() > 0.0) { + songIsPlaying = true; + Driver.soundController.playSong(song); } } }; @@ -270,6 +278,7 @@ public class SongPlayer extends Pane { * @throws UnsupportedAudioFileException */ public void cancel() { + Driver.soundController.playMenuSong(); gui.Driver.setBackground("assets/forest.png"); gameLoop.stop(); Driver.soundController.endSong(); |