aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2024-07-14 03:40:03 -0400
committersowgro <tpoke.ferrari@gmail.com>2024-07-14 03:40:03 -0400
commit550701557c1e021e45bddff92ad1a2e8c808e8e0 (patch)
tree219c5979d3b30843b88336ae755dd8e45a1e5471 /src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
parentcf8f3d35716cd93d0d5d123d80b07f9ae704f939 (diff)
downloadNPEhero-550701557c1e021e45bddff92ad1a2e8c808e8e0.tar.gz
NPEhero-550701557c1e021e45bddff92ad1a2e8c808e8e0.tar.bz2
NPEhero-550701557c1e021e45bddff92ad1a2e8c808e8e0.zip
NEW LEVEL EDITOR!!!!
Diffstat (limited to 'src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java')
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/gameplay/SongPlayer.java35
1 files changed, 10 insertions, 25 deletions
diff --git a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
index 39932a5..41976a9 100755
--- a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
+++ b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java
@@ -6,7 +6,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
-import java.util.Scanner;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
@@ -86,30 +85,16 @@ public class SongPlayer extends Pane {
* Establishes what the chart for the song is going to look like
* @throws FileNotFoundException
*/
- public void loadSong(File notes) throws FileNotFoundException {
- Scanner scan = new Scanner(new File(notes.getPath())); //file reader for reading in the notes from a notes.txt file
- try{
- while (scan.hasNext()) {
- String input = scan.next();
- if (input.charAt(0) == 'd') {
- dSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
- }
- else if (input.charAt(0) == 'f') {
- fSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
- }
- else if (input.charAt(0) == 's') {
- spaceSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
- }
- else if (input.charAt(0) == 'j') {
- jSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
- }
- else if (input.charAt(0) == 'k') {
- kSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
- }
+ 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)));
}
- } catch (NumberFormatException e) {
- e.printStackTrace();
- }
+ });
}
public SongPlayer(Level lvl, Difficulty d, Pane p, ScoreController cntrl) {
@@ -131,7 +116,7 @@ public class SongPlayer extends Pane {
scoreCounter = cntrl; //Uses the song's designated scoreCounter
try {
- loadSong(d.notes); //Calls the file loading from the song's notes.txt file
+ loadSong(); //Calls the file loading from the song's notes.txt file
} catch (FileNotFoundException e) {
e.printStackTrace();
}