diff options
| -rw-r--r-- | levels/testLevel2/easy/leaderboard.json | 2 | ||||
| -rw-r--r-- | src/gameplay/SongPlayer.java | 32 | ||||
| -rw-r--r-- | src/gameplay/TButton.java | 41 | ||||
| -rw-r--r-- | src/gameplay/Target.java | 50 | ||||
| -rw-r--r-- | src/gui/LevelSurround.java | 35 | 
5 files changed, 95 insertions, 65 deletions
| diff --git a/levels/testLevel2/easy/leaderboard.json b/levels/testLevel2/easy/leaderboard.json index 3daf19a..e922f47 100644 --- a/levels/testLevel2/easy/leaderboard.json +++ b/levels/testLevel2/easy/leaderboard.json @@ -1 +1 @@ -[{"date":"2023-06-02","score":17900,"name":"zbone"}]
\ No newline at end of file +[{"date":"2023-06-02","score":17900,"name":"zbone"},{"date":"2023-06-05","score":47900,"name":"tBONE"}]
\ No newline at end of file diff --git a/src/gameplay/SongPlayer.java b/src/gameplay/SongPlayer.java index 3d3fe7d..a1a6b45 100644 --- a/src/gameplay/SongPlayer.java +++ b/src/gameplay/SongPlayer.java @@ -59,23 +59,23 @@ public class SongPlayer extends Pane {  	HBox buttonBox = new HBox();	//used to align the buttons horizontally  	VBox place = new VBox();		//used to place the buttons within the frame -	TButton dButton = new TButton(Color.RED, 50, 50, 5);	//Initializes the button, each parameter is a placeholder that is changed later +	Target dButton = new Target(Color.RED, 50, 50, 5, 'd');	//Initializes the button, each parameter is a placeholder that is changed later  	Queue<NoteInfo> dSends = new LinkedList<NoteInfo>(); 		//Queue that dictates when to send the notes  	ArrayList<Block> dLane = new ArrayList<Block>(); 			//Array list containing all the notes currently on the field for that lane  																//process is repeated for the following four buttons -	TButton fButton = new TButton(Color.BLUE, 50, 50, 5); +	Target fButton = new Target(Color.BLUE, 50, 50, 5, 'f');  	Queue<NoteInfo> fSends = new LinkedList<NoteInfo>();  	ArrayList<Block> fLane = new ArrayList<Block>(); -	TButton sButton = new TButton(Color.GREEN, 50, 50, 5); +	Target sButton = new Target(Color.GREEN, 50, 50, 5, '_');  	Queue<NoteInfo> spaceSends = new LinkedList<NoteInfo>();  	ArrayList<Block> spaceLane = new ArrayList<Block>(); -	TButton jButton = new TButton(Color.PURPLE, 50, 50, 5); +	Target jButton = new Target(Color.PURPLE, 50, 50, 5, 'j');  	Queue<NoteInfo> jSends = new LinkedList<NoteInfo>();  	ArrayList<Block> jLane = new ArrayList<Block>(); -	TButton kButton = new TButton(Color.YELLOW, 50, 50, 5); +	Target kButton = new Target(Color.YELLOW, 50, 50, 5, 'k');  	Queue<NoteInfo> kSends = new LinkedList<NoteInfo>();  	ArrayList<Block> kLane = new ArrayList<Block>(); @@ -197,7 +197,7 @@ public class SongPlayer extends Pane {  	 * @param pos   the x pos of the note to be sent  	 * @param c     the color of the sent note  	 */ -	public void sendNote(Queue<NoteInfo> sends, ArrayList<Block> lane, TButton button) { +	public void sendNote(Queue<NoteInfo> sends, ArrayList<Block> lane, Target button) {  		if (sends.peek() != null && timer.time() > sends.peek().getTime()-(1000*(bpm/60000.0))) {  			TranslateTransition anim = new TranslateTransition(Duration.millis(TIME+60)); @@ -219,7 +219,7 @@ public class SongPlayer extends Pane {  			anim.setOnFinished(e -> {  				if (super.getChildren().removeAll(anim.getNode())){  					scoreCounter.miss(); -					FillTransition ft = new FillTransition(Duration.millis(500), button); +					FillTransition ft = new FillTransition(Duration.millis(500), button.rect);  					ft.setFromValue(Color.RED);  					ft.setToValue(button.getFillColor());  					ft.play(); @@ -234,12 +234,12 @@ public class SongPlayer extends Pane {  	 *   	 * @param button  	 */ -	private void genButton(TButton button) { -		button.heightProperty().bind(super.widthProperty().divide(8)); -		button.widthProperty().bind(super.widthProperty().divide(8)); -		button.arcHeightProperty().bind(super.widthProperty().divide(25)); -		button.arcWidthProperty().bind(super.widthProperty().divide(25)); -		button.strokeWidthProperty().bind(super.widthProperty().divide(120)); +	private void genButton(Target button) { +		button.rect.heightProperty().bind(super.widthProperty().divide(8)); +		button.rect.widthProperty().bind(super.widthProperty().divide(8)); +		button.rect.arcHeightProperty().bind(super.widthProperty().divide(25)); +		button.rect.arcWidthProperty().bind(super.widthProperty().divide(25)); +		button.rect.strokeWidthProperty().bind(super.widthProperty().divide(120));  	}  	/** @@ -308,7 +308,7 @@ public class SongPlayer extends Pane {  	 * @return  	 */  	private double distanceToGoal(Block note) { -		return Math.abs((super.getHeight() - note.getTranslateY()) - dButton.getY()); +		return Math.abs((super.getHeight() - note.getTranslateY()) - dButton.rect.getY());  	}  	/** @@ -317,13 +317,13 @@ public class SongPlayer extends Pane {  	 * @param button the button checking for a hit  	 * @return 2 for a perfect hit, 1 for a good hit, 0 for a miss, and -1 if there are no notes to hit  	 */ -	private int checkNote(ArrayList<Block> lane, TButton button) { +	private int checkNote(ArrayList<Block> lane, Target button) {  		if (lane.size() != 0)  		{  			double distance = distanceToGoal(lane.get(getClosestNote(lane)));  			if (lane.size() > 0 && distance < super.getHeight() / 3) { -				FillTransition ft = new FillTransition(Duration.millis(500), button); +				FillTransition ft = new FillTransition(Duration.millis(500), button.rect);  				ft.setToValue(button.getFillColor());  				super.getChildren().removeAll(lane.get(getClosestNote(lane))); diff --git a/src/gameplay/TButton.java b/src/gameplay/TButton.java deleted file mode 100644 index 6af1209..0000000 --- a/src/gameplay/TButton.java +++ /dev/null @@ -1,41 +0,0 @@ -//glowing block of color c (jfx node) - -package gameplay; - -import javafx.scene.paint.Color; -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 = 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(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; -    } -}
\ No newline at end of file diff --git a/src/gameplay/Target.java b/src/gameplay/Target.java new file mode 100644 index 0000000..6bfac18 --- /dev/null +++ b/src/gameplay/Target.java @@ -0,0 +1,50 @@ +//glowing block of color c (jfx node) + +package gameplay; + +import javafx.scene.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Text; + +public class Target extends StackPane +{ +    private Color col; +    private Color fill; +    private Text label; +    public Rectangle rect = new Rectangle(); +    public Target(Color c, double a, double b, int r, char key) +    { +        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); + + +        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(5); +    } + +    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; +    } + +    public Color getColor() { +        return col; +    } +}
\ No newline at end of file diff --git a/src/gui/LevelSurround.java b/src/gui/LevelSurround.java index 3739879..758a420 100644 --- a/src/gui/LevelSurround.java +++ b/src/gui/LevelSurround.java @@ -9,6 +9,7 @@ import gameplay.SongPlayer;  import javafx.geometry.Insets;  import javafx.geometry.Pos;  import javafx.scene.control.Button; +import javafx.scene.layout.AnchorPane;  import javafx.scene.layout.BorderPane;  import javafx.scene.layout.HBox;  import javafx.scene.layout.Pane; @@ -55,10 +56,15 @@ public class LevelSurround extends Pane          VBox titleTextBox = new VBox();          titleTextBox.setAlignment(Pos.TOP_RIGHT);          titleTextBox.getChildren().addAll(title, artist); - -        BorderPane topBar = new BorderPane(); -        topBar.setLeft(buttonBox); -        topBar.setRight(titleTextBox); +        titleTextBox.getStyleClass().add("box"); +        titleTextBox.setPadding(new Insets(10)); + +        AnchorPane topBar = new AnchorPane(); +        topBar.getChildren().addAll(buttonBox,titleTextBox); +        topBar.setLeftAnchor(buttonBox, 0.0); +        topBar.setRightAnchor(titleTextBox, 0.0); +        topBar.setTopAnchor(buttonBox, 0.0); +        topBar.setTopAnchor(titleTextBox, 0.0);          topBar.setPadding(new Insets(10)); @@ -74,7 +80,14 @@ public class LevelSurround extends Pane          scoreTextBox.setAlignment(Pos.BOTTOM_LEFT);          scoreTextBox.getChildren().addAll(scoreLabel,scoreDisplay);          scoreTextBox.setPadding(new Insets(10)); +        scoreTextBox.getStyleClass().add("box"); +        scoreTextBox.minWidthProperty().bind(scoreTextBox.heightProperty()); +        AnchorPane scoreBox = new AnchorPane(); +        scoreBox.getChildren().add(scoreTextBox); +        scoreBox.setLeftAnchor(scoreTextBox, 0.0); +        scoreBox.setBottomAnchor(scoreTextBox, 0.0); +        scoreBox.setPadding(new Insets(10));          Text comboLabel = new Text();          comboLabel.setText("Combo:"); @@ -88,17 +101,25 @@ public class LevelSurround extends Pane          comboTextBox.setAlignment(Pos.BOTTOM_RIGHT);          comboTextBox.getChildren().addAll(comboLabel,comboDisplay);          comboTextBox.setPadding(new Insets(10)); +        comboTextBox.getStyleClass().add("box"); +        comboTextBox.minWidthProperty().bind(comboTextBox.heightProperty()); + +        AnchorPane comboBox = new AnchorPane(); +        comboBox.getChildren().add(comboTextBox); +        comboBox.setRightAnchor(comboTextBox, 0.0); +        comboBox.setBottomAnchor(comboTextBox, 0.0); +        comboBox.setPadding(new Insets(10));          game.minWidthProperty().bind(super.prefHeightProperty().multiply(0.66));          game.minHeightProperty().bind(super.prefHeightProperty());          game.getStyleClass().add("box"); -        comboTextBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2)); -        scoreTextBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2)); +        comboBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2)); +        scoreBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2));          HBox centerBox = new HBox(); -        centerBox.getChildren().addAll(comboTextBox, game, scoreTextBox); +        centerBox.getChildren().addAll(comboBox, game, scoreBox);          centerBox.setAlignment(Pos.BOTTOM_CENTER);          StackPane root = new StackPane(); | 
