diff options
Diffstat (limited to 'src/main/java/net/sowgro/npehero/gameplay')
3 files changed, 14 insertions, 29 deletions
diff --git a/src/main/java/net/sowgro/npehero/gameplay/Block.java b/src/main/java/net/sowgro/npehero/gameplay/Block.java index 9d68ab6..5d35ccc 100755 --- a/src/main/java/net/sowgro/npehero/gameplay/Block.java +++ b/src/main/java/net/sowgro/npehero/gameplay/Block.java @@ -16,24 +16,20 @@ public class Block extends Rectangle public Color color; public Note note; - public Block(Color color, double width, double height, int cornerRadius, boolean useDropShadow, Note note) + public Block(Color color, boolean useDropShadow, Note note) { 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 Block(Color color, Note note) { + this(color, true, note); } public void enableDropShadow() { diff --git a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java index 91a3ecc..f3abf91 100755 --- a/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java +++ b/src/main/java/net/sowgro/npehero/gameplay/SongPlayer.java @@ -60,7 +60,7 @@ public class SongPlayer extends HBox { // create targets for (int i = 0; i < lanes.length; i++) { lanes[i] = new Lane(); - var tmp = new Target(level.colors[i], 50, 50, 20, Control.lanes[i].targetString()); + var tmp = new Target(level.colors[i], Control.lanes[i].targetString()); bindTarget(tmp); lanes[i].target = tmp; } @@ -79,7 +79,7 @@ public class SongPlayer extends HBox { } })); // schedule the game over screen to show at the end - timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(songLength + START_DELAY), _ -> { + timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(songLength + FALL_TIME + START_DELAY), _ -> { Driver.setMenu(new GameOver(level, diff, prev, scoreCounter.getScore())); cancel(); })); @@ -125,7 +125,7 @@ public class SongPlayer extends HBox { public void sendNote(Note note) { Lane lane = lanes[note.lane]; - Block block = new Block(lane.target.getColor(), 50, 50, 15); + Block block = new Block(lane.target.getColor(), note); block.setCache(true); block.setCacheHint(CacheHint.SPEED); block.xProperty().bind(lane.pane.widthProperty().subtract(block.widthProperty()).divide(2)); @@ -136,7 +136,7 @@ public class SongPlayer extends HBox { TranslateTransition anim = new TranslateTransition(Duration.seconds(FALL_TIME + 0.105)); anim.setInterpolator(Interpolator.LINEAR); - anim.byYProperty().bind(super.heightProperty().add(block.getHeight()).add(75)); + anim.byYProperty().bind(lane.pane.heightProperty().add(block.getHeight()).add(75)); anim.setNode(block); anim.play(); anim.setOnFinished(_ -> { @@ -157,7 +157,7 @@ public class SongPlayer extends HBox { */ private void bindTarget(Target target) { bindBlock(target.rect); -// target.rect.strokeWidthProperty().bind(super.widthProperty().divide(120)); + target.rect.strokeWidthProperty().bind(super.heightProperty().multiply(4/1080.0)); } private void bindBlock(Rectangle block) { diff --git a/src/main/java/net/sowgro/npehero/gameplay/Target.java b/src/main/java/net/sowgro/npehero/gameplay/Target.java index 45907d3..9f2b4ea 100755 --- a/src/main/java/net/sowgro/npehero/gameplay/Target.java +++ b/src/main/java/net/sowgro/npehero/gameplay/Target.java @@ -9,37 +9,26 @@ import javafx.scene.text.Text; public class Target extends StackPane { - private Color col; - private Color fill; - private Text label; + private final Color col; + private final Color fill; public Rectangle rect = new Rectangle(); - public Target(Color c, double a, double b, int r, String key) + + public Target(Color c, String key) { - label = new Text(key); + Text label = new Text(key); label.getStyleClass().add("t3"); label.scaleXProperty().bind(super.widthProperty().divide(50)); label.scaleYProperty().bind(label.scaleXProperty()); - super.getChildren().addAll(rect,label); + super.getChildren().addAll(rect, label); col = c; fill = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.45); rect.setFill(fill); - rect.setWidth(a); - rect.setHeight(b); - rect.setArcHeight(r); - rect.setArcWidth(r); rect.setStroke(col); rect.setStrokeWidth(4); } - public void setColor(Color c) { - col = c; - fill = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.45); - rect.setFill(fill); - rect.setStroke(c); - } - public Color getFillColor() { return fill; } |