aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/sowgro/npehero/gameplay
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/sowgro/npehero/gameplay')
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/gameplay/SongPlayer.java25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
index b61d11c..2f95ee8 100755
--- a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
+++ b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
@@ -42,11 +42,11 @@ import javafx.util.*;
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 double songLength; //initializes the length of the song in terms of the song's bpm, to be read in later
private EventHandler<KeyEvent> eventHandler;
- private File song;
+ private Media song;
private boolean songIsPlaying = false;
private boolean missMute = false;
@@ -89,11 +89,11 @@ public class SongPlayer extends Pane {
public void loadSong() throws FileNotFoundException {
difficulty.notes.list.forEach(e -> {
switch (e.lane) {
- case 0 -> dSends.add(new NoteInfo(e.time.get() * (difficulty.bpm / 60)));
- case 1 -> fSends.add(new NoteInfo(e.time.get() * (difficulty.bpm / 60)));
- case 2 -> spaceSends.add(new NoteInfo(e.time.get() * (difficulty.bpm / 60)));
- case 3 -> jSends.add(new NoteInfo(e.time.get() * (difficulty.bpm / 60)));
- case 4 -> kSends.add(new NoteInfo(e.time.get() * (difficulty.bpm / 60)));
+ case 0 -> dSends.add(new NoteInfo(e.time.get() * (bpm / 60)));
+ case 1 -> fSends.add(new NoteInfo(e.time.get() * (bpm / 60)));
+ case 2 -> spaceSends.add(new NoteInfo(e.time.get() * (bpm / 60)));
+ case 3 -> jSends.add(new NoteInfo(e.time.get() * (bpm / 60)));
+ case 4 -> kSends.add(new NoteInfo(e.time.get() * (bpm / 60)));
}
});
}
@@ -105,14 +105,19 @@ public class SongPlayer extends Pane {
if (lvl.background != null) {
Driver.setBackground(lvl.background);
}
- bpm = d.bpm; //Reads the song's bpm from a metadata file
+ bpm = 60.0; //Reads the song's bpm from a metadata file
level = lvl;
difficulty = d;
pane = p;
//System.out.println(d.bpm + " " + d.numBeats);
- songLength = d.numBeats;
+ if (d.endTime != 0) {
+ songLength = d.endTime;
+ }
+ else {
+ songLength = d.level.song.getDuration().toSeconds();
+ }
timer = new Timer(bpm); //Sets the timer's bpm to that of the song
scoreCounter = cntrl; //Uses the song's designated scoreCounter
@@ -255,7 +260,7 @@ public class SongPlayer extends Pane {
}
if (!songIsPlaying && timer.time() > 0.0) {
songIsPlaying = true;
- Sound.playSong(new Media(song.toURI().toString()));
+ Sound.playSong(song);
}
}
};