aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAidan Ross <aross02@fairport.org>2023-05-26 10:57:20 -0400
committerAidan Ross <aross02@fairport.org>2023-05-26 10:57:20 -0400
commit306ba44c51d102bc6608ee901cb268ec592325fc (patch)
treedc0dce3750dedbf618d753dd2ff8db3684379a53
parent576c665f56a9b3d42541e730a294898dc6e6536f (diff)
downloadNPEhero-306ba44c51d102bc6608ee901cb268ec592325fc.tar.gz
NPEhero-306ba44c51d102bc6608ee901cb268ec592325fc.tar.bz2
NPEhero-306ba44c51d102bc6608ee901cb268ec592325fc.zip
update on file reading and reading color from metadata
-rw-r--r--levels/testLevel/hard/notes.txt33
-rw-r--r--levels/testLevel/medium/notes.txt5
-rw-r--r--src/gameplay/SongPlayer.java79
-rw-r--r--src/gameplay/TButton.java19
4 files changed, 76 insertions, 60 deletions
diff --git a/levels/testLevel/hard/notes.txt b/levels/testLevel/hard/notes.txt
index e69de29..2e181de 100644
--- a/levels/testLevel/hard/notes.txt
+++ b/levels/testLevel/hard/notes.txt
@@ -0,0 +1,33 @@
+d4.000
+d4.333
+d4.666
+f5.000
+k5.500
+s6.000
+j6.000
+j6.250
+d6.500
+j6.750
+s7.000
+f7.500
+j7.750
+s8.000
+f8.500
+j8.500
+d9.000
+s9.000
+k9.000
+s9.500
+k10.000
+d10.000
+k10.333
+f10.333
+k10.666
+s10.666
+d11.000
+s11.000
+d11.333
+j11.333
+d11.666
+k11.666
+s12.000 \ No newline at end of file
diff --git a/levels/testLevel/medium/notes.txt b/levels/testLevel/medium/notes.txt
index e69de29..5b0d70a 100644
--- a/levels/testLevel/medium/notes.txt
+++ b/levels/testLevel/medium/notes.txt
@@ -0,0 +1,5 @@
+d4.00
+f5.00
+s6.00
+j7.00
+k8.00 \ No newline at end of file
diff --git a/src/gameplay/SongPlayer.java b/src/gameplay/SongPlayer.java
index f594b81..10caf46 100644
--- a/src/gameplay/SongPlayer.java
+++ b/src/gameplay/SongPlayer.java
@@ -2,6 +2,7 @@ package gameplay;
import java.io.File;
import java.io.FileNotFoundException;
+import java.io.FileReader;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Queue;
@@ -73,71 +74,36 @@ public class SongPlayer extends Pane {
* @throws FileNotFoundException
*/
public void loadSong(File notes) throws FileNotFoundException {
- System.out.println("TEST 2");
- try (Scanner scan = new Scanner(notes)) {
+ Scanner scan = new Scanner(new File(notes.getPath()));
+ System.out.println(notes.getPath());
+ try{
while (scan.hasNext()) {
- if (scan.next().charAt(0) == 'd') {
- dSends.add(new NoteInfo(Double.parseDouble(scan.next().substring(1))));
+ String input = scan.next();
+ if (input.charAt(0) == 'd') {
+ dSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
}
- if (scan.next().charAt(0) == 'f') {
- fSends.add(new NoteInfo(Double.parseDouble(scan.next().substring(1))));
+ else if (input.charAt(0) == 'f') {
+ fSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
}
- if (scan.next().charAt(0) == 's') {
- spaceSends.add(new NoteInfo(Double.parseDouble(scan.next().substring(1))));
+ else if (input.charAt(0) == 's') {
+ spaceSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
}
- if (scan.next().charAt(0) == 'j') {
- jSends.add(new NoteInfo(Double.parseDouble(scan.next().substring(1))));
+ else if (input.charAt(0) == 'j') {
+ jSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
}
- if (scan.next().charAt(0) == 'k') {
- kSends.add(new NoteInfo(Double.parseDouble(scan.next().substring(1))));
+ else if (input.charAt(0) == 'k') {
+ kSends.add(new NoteInfo(Double.parseDouble(input.substring(1))));
}
}
- // dSends.add(new NoteInfo(4.000));
- // dSends.add(new NoteInfo(4.333));
- // dSends.add(new NoteInfo(4.666));
- // fSends.add(new NoteInfo(5.000));
- // kSends.add(new NoteInfo(5.500));
- // spaceSends.add(new NoteInfo(6.000));
- // jSends.add(new NoteInfo(6.000));
- // jSends.add(new NoteInfo(6.250));
- // dSends.add(new NoteInfo(6.500));
- // jSends.add(new NoteInfo(6.750));
- // spaceSends.add(new NoteInfo(7.000));
- // fSends.add(new NoteInfo(7.500));
- // jSends.add(new NoteInfo(7.750));
- // spaceSends.add(new NoteInfo(8.000));
- // fSends.add(new NoteInfo(8.500));
- // jSends.add(new NoteInfo(8.500));
- // dSends.add(new NoteInfo(9.000));
- // spaceSends.add(new NoteInfo(9.000));
- // kSends.add(new NoteInfo(9.000));
- // spaceSends.add(new NoteInfo(9.500));
} catch (NumberFormatException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
-
- // kSends.add(new NoteInfo(10.000));
- // dSends.add(new NoteInfo(10.000));
- // kSends.add(new NoteInfo(10.333));
- // fSends.add(new NoteInfo(10.333));
- // kSends.add(new NoteInfo(10.666));
- // spaceSends.add(new NoteInfo(10.666));
- // dSends.add(new NoteInfo(11.000));
- // spaceSends.add(new NoteInfo(11.000));
- // dSends.add(new NoteInfo(11.333));
-
- // jSends.add(new NoteInfo(11.333));
- // dSends.add(new NoteInfo(11.666));
- // kSends.add(new NoteInfo(11.666));
- // spaceSends.add(new NoteInfo(12.000));
}
public SongPlayer(main.Level lvl, Difficulty d, Pane p, ScoreController cntrl) {
bpm = d.bpm;
- timer = new Timer(bpm);
+ timer = new Timer(60);
- System.out.println("test");
try {
loadSong(d.notes);
@@ -145,7 +111,6 @@ public class SongPlayer extends Pane {
e.printStackTrace();
}
-
Rectangle field = new Rectangle(50, 50, new Color(0, 0, 0, 0.7));
field.heightProperty().bind(super.heightProperty());
field.widthProperty().bind(super.widthProperty());
@@ -153,11 +118,11 @@ public class SongPlayer extends Pane {
goalPerfect.heightProperty().bind(super.heightProperty().divide(32));
goalPerfect.heightProperty().bind(super.widthProperty());
- dButton.setFill(lvl.colors[0]);
- fButton.setFill(lvl.colors[1]);
- sButton.setFill(lvl.colors[2]);
- jButton.setFill(lvl.colors[3]);
- kButton.setFill(lvl.colors[4]);
+ dButton.setColor(lvl.colors[0]);
+ fButton.setColor(lvl.colors[1]);
+ sButton.setColor(lvl.colors[2]);
+ jButton.setColor(lvl.colors[3]);
+ kButton.setColor(lvl.colors[4]);
genButton(dButton);
genButton(fButton);
genButton(sButton);
@@ -311,7 +276,7 @@ public class SongPlayer extends Pane {
if (lane.size() > 0 && distance < super.getHeight() / 3) {
FillTransition ft = new FillTransition(Duration.millis(500), button);
- ft.setToValue(button.getColor());
+ ft.setToValue(button.getFillColor());
super.getChildren().removeAll(lane.get(getClosestNote(lane)));
lane.remove(lane.get(getClosestNote(lane)));
diff --git a/src/gameplay/TButton.java b/src/gameplay/TButton.java
index 98f954c..6af1209 100644
--- a/src/gameplay/TButton.java
+++ b/src/gameplay/TButton.java
@@ -8,20 +8,33 @@ import javafx.scene.shape.Rectangle;
public class TButton extends Rectangle
{
private Color col;
+ private Color fill;
public TButton(Color c, double a, double b, int r)
{
super();
- col = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.45);
- super.setFill(col);
+ col = c;
+ fill = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.45);
+ super.setFill(fill);
super.setWidth(a);
super.setHeight(b);
super.setArcHeight(r);
super.setArcWidth(r);
- super.setStroke(c);
+ super.setStroke(col);
super.setStrokeWidth(5);
}
+ public void setColor(Color c) {
+ col = c;
+ fill = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.45);
+ super.setFill(fill);
+ super.setStroke(c);
+ }
+
+ public Color getFillColor() {
+ return fill;
+ }
+
public Color getColor() {
return col;
}