diff options
author | Zach Jordan <zxjordan5@gmail.com> | 2023-05-31 08:35:25 -0400 |
---|---|---|
committer | Zach Jordan <zxjordan5@gmail.com> | 2023-05-31 08:35:25 -0400 |
commit | 503bcda9b5ea81c7fe242e2e7a1a2bbd1bea8044 (patch) | |
tree | 6f48bfb3525d038ca1cb86a0bc710db030ea66c0 /src | |
parent | d740fddf3d10db07363523e854d7db99fda575b7 (diff) | |
parent | b1f10378237ecdfe9153cd42af85bbe34b2e92dc (diff) | |
download | NPEhero-503bcda9b5ea81c7fe242e2e7a1a2bbd1bea8044.tar.gz NPEhero-503bcda9b5ea81c7fe242e2e7a1a2bbd1bea8044.tar.bz2 NPEhero-503bcda9b5ea81c7fe242e2e7a1a2bbd1bea8044.zip |
Merge branch 'main' of https://gitlab.sowgro.net/guitarheros/guitarhero
Diffstat (limited to 'src')
-rw-r--r-- | src/gameplay/SongPlayer.java | 23 | ||||
-rw-r--r-- | src/gui/LevelSurround.java | 21 |
2 files changed, 32 insertions, 12 deletions
diff --git a/src/gameplay/SongPlayer.java b/src/gameplay/SongPlayer.java index acf9d6b..f76f5e3 100644 --- a/src/gameplay/SongPlayer.java +++ b/src/gameplay/SongPlayer.java @@ -45,7 +45,8 @@ public class SongPlayer extends Pane { private int 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 - sound.AudioFilePlayer music; + AudioFilePlayer music; + private main.Level level; private Difficulty difficulty; private Pane pane; @@ -110,13 +111,15 @@ public class SongPlayer extends Pane { public SongPlayer(main.Level lvl, Difficulty d, Pane p, ScoreController cntrl) { bpm = d.bpm; //Reads the song's bpm from a metadata file - level = lvl; difficulty = d; pane = p; + music = new AudioFilePlayer(difficulty.song.getPath()); - songLength = d.numBeats; - timer = new Timer(d.bpm); //Sets the timer's bpm to that of the song + System.out.println(d.bpm + " " + d.numBeats); + + songLength = 28; //PLACEHOLDER BPM AND TIMER + timer = new Timer(120); //Sets the timer's bpm to that of the song scoreCounter = cntrl; //Uses the song's designated scoreCounter try { @@ -174,10 +177,6 @@ public class SongPlayer extends Pane { root.getChildren().addAll(place); //aligns the components within the pane super.getChildren().addAll(root); //puts all of the combonents in the pane to be rendered - - gameLoop.start(); //starts the gameLoop, a periodic backround task runner that runs the methods within it 60 times every second - music = new AudioFilePlayer(d.song.getPath()); - music.play(); } /** @@ -257,8 +256,14 @@ public class SongPlayer extends Pane { } }; + //starts the gameLoop, a periodic backround task runner that runs the methods within it 60 times every second + public void start() { + music.play(); + gameLoop.start(); + } + /** - * Stops the gameloop and the music + * Stops the gameloop * @throws LineUnavailableException * @throws IOException * @throws UnsupportedAudioFileException diff --git a/src/gui/LevelSurround.java b/src/gui/LevelSurround.java index e84071e..3f10925 100644 --- a/src/gui/LevelSurround.java +++ b/src/gui/LevelSurround.java @@ -1,5 +1,10 @@ package gui; +import java.io.IOException; + +import javax.sound.sampled.LineUnavailableException; +import javax.sound.sampled.UnsupportedAudioFileException; + import gameplay.SongPlayer; import javafx.geometry.Insets; import javafx.geometry.Pos; @@ -13,9 +18,10 @@ import javafx.scene.text.Text; import main.Difficulty; import main.Level; import main.ScoreController; +import sound.AudioFilePlayer; public class LevelSurround extends Pane -{ +{ /* * this class is a layout class, most of its purpose is to place UI elements like Buttons within Panes like VBoxes. * the creation of these UI elements are mostly not commented due to their repetitive and self explanatory nature. @@ -28,7 +34,14 @@ public class LevelSurround extends Pane Button exit = new Button(); exit.setText("Back"); - exit.setOnAction(e -> Driver.setMenu(prev)); + exit.setOnAction(e -> { + Driver.setMenu(prev); + try { + game.cancel(); + } catch (UnsupportedAudioFileException | IOException | LineUnavailableException e1) { + e1.printStackTrace(); + } + }); Button pause = new Button(); pause.setText("Pause"); @@ -92,7 +105,7 @@ public class LevelSurround extends Pane scoreTextBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2)); HBox centerBox = new HBox(); - centerBox.getChildren().addAll(comboTextBox,game, scoreTextBox); + centerBox.getChildren().addAll(comboTextBox, game, scoreTextBox); centerBox.setAlignment(Pos.BOTTOM_CENTER); StackPane root = new StackPane(); @@ -122,5 +135,7 @@ public class LevelSurround extends Pane testfinish.setText(level.getTitle() + "launch game end"); testfinish.setOnAction(e -> Driver.setMenu(new GameOver(level, difficulty, prev, sc.getScore()))); Driver.debug.addButton(testfinish); + + game.start(); } }
\ No newline at end of file |