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/Block.java37
-rwxr-xr-xsrc/main/java/net/sowgro/npehero/gameplay/SongPlayer.java35
2 files changed, 38 insertions, 34 deletions
diff --git a/src/main/java/net/sowgro/npehero/gameplay/Block.java b/src/main/java/net/sowgro/npehero/gameplay/Block.java
index 5bc9d9c..c55a7bf 100755
--- a/src/main/java/net/sowgro/npehero/gameplay/Block.java
+++ b/src/main/java/net/sowgro/npehero/gameplay/Block.java
@@ -6,22 +6,41 @@ import javafx.scene.effect.BlurType;
import javafx.scene.effect.DropShadow;
import javafx.scene.paint.Color;
import javafx.scene.shape.Rectangle;
+import net.sowgro.npehero.main.Note;
+/**
+ * A block is a visual representation of a note on the screen. This is used both in the editor and in during the game play.
+ */
public class Block extends Rectangle
{
- public Block(Color c, double a, double b, int r)
+ public Color color;
+ public Note note;
+
+ public Block(Color color, double width, double height, int cornerRadius, boolean useDropShadow, Note note)
{
- super();
+ this.note = note;
+ this.color = color;
+
+ super.setFill(color);
+ super.setWidth(width);
+ super.setHeight(height);
+ super.setArcHeight(cornerRadius);
+ super.setArcWidth(cornerRadius);
+
+ if (useDropShadow) {
+ enableDropShadow();
+ }
+ }
+
+ public Block(Color color, double width, double height, int cornerRadius) {
+ this(color, width, height, cornerRadius, true, null);
+ }
+
+ public void enableDropShadow() {
DropShadow dropShadow = new DropShadow();
dropShadow.setRadius(200.0);
- dropShadow.setColor(c);
+ dropShadow.setColor(color);
dropShadow.setBlurType(BlurType.GAUSSIAN);
-
- super.setFill(c);
- super.setWidth(a);
- super.setHeight(b);
- super.setArcHeight(r);
- super.setArcWidth(r);
super.setEffect(dropShadow);
}
} \ No newline at end of file
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();
}