aboutsummaryrefslogtreecommitdiff
path: root/src/gameplay/SongPlayer.java
diff options
context:
space:
mode:
authorZach Jordan <zxjordan5@gmail.com>2023-06-05 08:38:37 -0400
committerZach Jordan <zxjordan5@gmail.com>2023-06-05 08:38:37 -0400
commit0208dbcecb7c60a18e9c87d07e405dbb3b53fd23 (patch)
tree5ee377fe25098f377765b4d126989c79978b9970 /src/gameplay/SongPlayer.java
parentb6826c6ba281366efc60e89d73d3b6f81d4f2b80 (diff)
parentc0e5adb06fa5076ae1f024f004605f7f4e442957 (diff)
downloadNPEhero-0208dbcecb7c60a18e9c87d07e405dbb3b53fd23.tar.gz
NPEhero-0208dbcecb7c60a18e9c87d07e405dbb3b53fd23.tar.bz2
NPEhero-0208dbcecb7c60a18e9c87d07e405dbb3b53fd23.zip
Merge branch 'main' of https://gitlab.sowgro.net/guitarheros/guitarhero
Diffstat (limited to 'src/gameplay/SongPlayer.java')
-rw-r--r--src/gameplay/SongPlayer.java15
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();