aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAidan Ross <aross02@fairport.org>2023-05-24 08:54:44 -0400
committerAidan Ross <aross02@fairport.org>2023-05-24 08:54:44 -0400
commitb47c8be84cc5b269e32dc44f7e67a1dd426d5349 (patch)
tree14d1eecd5182b92d4ee7c99cff1cbd3a758ffbb0 /src
parent4b24f4b8e14cdcb6f03db1a3bb14a7417c638672 (diff)
downloadNPEhero-b47c8be84cc5b269e32dc44f7e67a1dd426d5349.tar.gz
NPEhero-b47c8be84cc5b269e32dc44f7e67a1dd426d5349.tar.bz2
NPEhero-b47c8be84cc5b269e32dc44f7e67a1dd426d5349.zip
Trying to combine every file oh my god
Diffstat (limited to 'src')
-rw-r--r--src/fallTest/Driver.java4
-rw-r--r--src/fallTest/LaneInfo.java28
-rw-r--r--src/fallTest/NoteNode.java20
-rw-r--r--src/fallTest/newSongPlayer.java4
-rw-r--r--src/gui/LevelSurround.java3
-rw-r--r--src/test/Block.java27
-rw-r--r--src/test/JFXaudioPlayer.java29
-rw-r--r--src/test/KeyDetection.java27
-rw-r--r--src/test/Level.java106
-rw-r--r--src/test/NoteTest.java35
-rw-r--r--src/test/SongPlayer.java97
-rw-r--r--src/test/SongPlayer2.java232
-rw-r--r--src/test/Table.java112
-rw-r--r--src/test/focusTest.java46
14 files changed, 6 insertions, 764 deletions
diff --git a/src/fallTest/Driver.java b/src/fallTest/Driver.java
index 08a424b..bb1d73e 100644
--- a/src/fallTest/Driver.java
+++ b/src/fallTest/Driver.java
@@ -33,9 +33,9 @@ public class Driver extends Application
Scene primaryScene = new Scene(primaryPane, 800, 600);
primaryScene.getStylesheets().add("gui/style.css");
primaryStage.setScene(primaryScene);
- newSongPlayer player = new newSongPlayer();
+ //newSongPlayer player = new newSongPlayer();
primaryStage.setTitle("TEST");
- primaryPane.getChildren().add(player);
+ //primaryPane.getChildren().add(player);
setBackground("assets/water.png");
primaryStage.show();
}
diff --git a/src/fallTest/LaneInfo.java b/src/fallTest/LaneInfo.java
deleted file mode 100644
index 7fe5567..0000000
--- a/src/fallTest/LaneInfo.java
+++ /dev/null
@@ -1,28 +0,0 @@
-package fallTest;
-
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.Queue;
-
-import javax.swing.JButton;
-
-public class LaneInfo {
- //test
- Queue<NoteInfo> sends = new LinkedList<NoteInfo>(); //Queue that dictates when to send the notes
- ArrayList<Block> nodes = new ArrayList<Block>(); //Array list containing all the notes currently on the field
- public void addSends(int t) {
- sends.add(new NoteInfo(t));
- }
-
- public void addNodes(int t) {
- nodes.add(new Block());
- }
-
- public ArrayList<Block> getNodes() {
- return nodes;
- }
-
- public Queue<NoteInfo> getSends() {
- return sends;
- }
-}
diff --git a/src/fallTest/NoteNode.java b/src/fallTest/NoteNode.java
deleted file mode 100644
index 64e1b8a..0000000
--- a/src/fallTest/NoteNode.java
+++ /dev/null
@@ -1,20 +0,0 @@
-package fallTest;
-
-import javafx.animation.*;
-import javafx.util.Duration;
-
-public class NoteNode {
- private final int TIME = 20;
- private NoteField info;
- private Block vis;
- TranslateTransition anim = new TranslateTransition(Duration.millis(TIME));
- public NoteNode(NoteField newInfo, Block newVis) {
- vis=newVis;
- info = newInfo;
- anim.setNode(vis);
- anim.setByY(height);
- anim.setCycleCount(1);
- anim.setAutoReverse(false);
- anim.play();
- }
-}
diff --git a/src/fallTest/newSongPlayer.java b/src/fallTest/newSongPlayer.java
index 02f828a..d93d098 100644
--- a/src/fallTest/newSongPlayer.java
+++ b/src/fallTest/newSongPlayer.java
@@ -106,7 +106,7 @@ public class newSongPlayer extends Pane
spaceSends.add(new NoteInfo(12000));
}
- public newSongPlayer(Level lvl, Difficulty d, Pane p, ScoreController cntrl){
+ public newSongPlayer(main.Level lvl, Difficulty d, Pane p, ScoreController cntrl){
}
@@ -129,7 +129,7 @@ public class newSongPlayer extends Pane
this.getScene().setOnKeyPressed(e -> {
if (e.getCode() == KeyCode.D) {
System.out.println("D");
- if (dLane.size() > 0 && distanceToGoal(dLane.get(getClosestNote(dLane))) < ()) {
+ if (dLane.size() > 0 && distanceToGoal(dLane.get(getClosestNote(dLane))) < 20) {
super.getChildren().removeAll(dLane.get(getClosestNote(dLane)));
dLane.remove(dLane.get(getClosestNote(dLane)));
System.out.println("Hit");
diff --git a/src/gui/LevelSurround.java b/src/gui/LevelSurround.java
index ba3b5fd..2f9ec75 100644
--- a/src/gui/LevelSurround.java
+++ b/src/gui/LevelSurround.java
@@ -1,5 +1,6 @@
package gui;
+import fallTest.newSongPlayer;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
@@ -88,7 +89,7 @@ public class LevelSurround extends Pane
comboTextBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2));
scoreTextBox.minWidthProperty().bind(super.prefWidthProperty().subtract(game.minWidthProperty()).divide(2));
- //new Game(level, difficulty, prev, sc)
+ new fallTest.newSongPlayer(level, difficulty, prev, sc);
HBox centerBox = new HBox();
centerBox.getChildren().addAll(comboTextBox,game, scoreTextBox);
diff --git a/src/test/Block.java b/src/test/Block.java
deleted file mode 100644
index 42cedba..0000000
--- a/src/test/Block.java
+++ /dev/null
@@ -1,27 +0,0 @@
-//glowing block of color c (jfx node)
-
-package gui;
-
-import javafx.scene.effect.BlurType;
-import javafx.scene.effect.DropShadow;
-import javafx.scene.paint.Color;
-import javafx.scene.shape.Rectangle;
-
-public class Block extends Rectangle
-{
- public Block(Color c, double a, double b, int r)
- {
- super();
- DropShadow dropShadow = new DropShadow();
- dropShadow.setRadius(200.0);
- dropShadow.setColor(c);
- 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/test/JFXaudioPlayer.java b/src/test/JFXaudioPlayer.java
deleted file mode 100644
index 2f12e20..0000000
--- a/src/test/JFXaudioPlayer.java
+++ /dev/null
@@ -1,29 +0,0 @@
-package test;
-
-import java.io.File;
-import java.io.IOException;
-
-import javafx.application.Application;
-import javafx.fxml.FXMLLoader;
-import javafx.scene.Parent;
-import javafx.scene.media.Media;
-import javafx.scene.media.MediaPlayer;
-import javafx.stage.Stage;
-
-public class JFXaudioPlayer extends Application{
-
- public static void main(String[] args)
- {
- launch(args);
- }
-
- @Override
- public void start(Stage primaryStage)
- {
- // primaryStage.show();
- String musicFile = "EXAMPLE.mp3"; // For example
- Media sound = new Media(new File(musicFile).toURI().toString());
- MediaPlayer mediaPlayer = new MediaPlayer(sound);
- mediaPlayer.play();
- }
-} \ No newline at end of file
diff --git a/src/test/KeyDetection.java b/src/test/KeyDetection.java
deleted file mode 100644
index 447b101..0000000
--- a/src/test/KeyDetection.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*Name:
- *Date:
- *Period:
- *Teacher:
- *Description:
- */
-package test;
-
-import javax.swing.*;
-import java.awt.event.ActionEvent;
-
-public class KeyDetection extends AbstractAction
-{
- long timeStart = System.currentTimeMillis();
- private char key;
- public KeyDetection(char ch){
- key = ch;
- }
-
- public void actionPerformed(ActionEvent e)
- {
- // TODO Auto-generated method stub
- int time = (int)((System.currentTimeMillis()-timeStart));
- System.out.println(key + ": " + time);
- }
-
-}
diff --git a/src/test/Level.java b/src/test/Level.java
deleted file mode 100644
index 6647b6d..0000000
--- a/src/test/Level.java
+++ /dev/null
@@ -1,106 +0,0 @@
-package test;
-
-import gui.Block;
-import javafx.application.Application;
-import javafx.event.ActionEvent;
-import javafx.event.EventHandler;
-import javafx.geometry.Insets;
-import javafx.scene.Scene;
-import javafx.scene.control.Button;
-import javafx.scene.effect.BlurType;
-import javafx.scene.effect.DropShadow;
-import javafx.scene.layout.Background;
-import javafx.scene.layout.BackgroundFill;
-import javafx.scene.layout.BorderPane;
-import javafx.scene.layout.CornerRadii;
-import javafx.scene.layout.GridPane;
-import javafx.scene.layout.Pane;
-import javafx.scene.paint.Color;
-import javafx.stage.Stage;
-
-// will eventually extend pane
-public class Level extends Application {
- public static void main(String[] args) {
- launch(args);
- }
-
- @Override
- public void start(Stage primaryStage) {
- primaryStage.setTitle("program");
-
- BorderPane background = new BorderPane();
- Scene game = new Scene(background, 800, 600);
- GridPane blockGrid = new GridPane();
- blockGrid.setBackground(new Background(new BackgroundFill(Color.BLACK, CornerRadii.EMPTY, Insets.EMPTY)));
- background.setCenter(blockGrid);
-
- blockGrid.maxWidthProperty().bind(game.heightProperty().multiply(0.53));
- blockGrid.maxHeightProperty().bind(game.heightProperty());
- System.out.println(game.heightProperty());
-
- //blockGrid.setMaxHeight(700);
- //blockGrid.setMaxWidth(500);
- //blockGrid.setScaleX(1);
- //blockGrid.setScaleY(1);
- //blockGrid.scaleXProperty().bind(game.heightProperty().divide(1000));
- //blockGrid.scaleYProperty().bind(game.heightProperty().divide(1000));
- //blockGrid.hgapProperty().bind(blockGrid.heightProperty().divide(11));
- //blockGrid.vgapProperty().bind(blockGrid.widthProperty().divide(21));
- blockGrid.setVgap(10);
- blockGrid.setHgap(25);
-
- int blocksize = 50;
- //AnchorPane b11 = new AnchorPane();
- //b11.getChildren().add(new Block(Color.ORANGE, b11, 10));
- Block b1 = new Block(Color.RED, blocksize, blocksize, 10);
- //b1.heightProperty().bind(blockGrid.heightProperty().divide((blockGrid.getColumnCount()*2)+1));
- //b1.widthProperty().bind(blockGrid.widthProperty().divide((blockGrid.getRowCount()*2)+1));
-
- Block b2 = new Block(Color.BLUE, blocksize, blocksize, 10);
- //b2.heightProperty().bind(blockGrid.heightProperty().divide(21));
- //b2.widthProperty().bind(blockGrid.widthProperty().divide(11));
-
- Block b3 = new Block(Color.GREEN, blocksize, blocksize, 10);
- //b3.heightProperty().bind(blockGrid.heightProperty().divide(21));
- //b3.widthProperty().bind(blockGrid.widthProperty().divide(11));
-
- Block b4 = new Block(Color.YELLOW, blocksize, blocksize, 10);
- //b4.heightProperty().bind(blockGrid.heightProperty().divide(21));
- //b4.widthProperty().bind(blockGrid.widthProperty().divide(11));
-
- Pane test = new Pane();
-
- Block b5 = new Block(Color.ORANGE, blocksize, blocksize, 10);
- DropShadow dropShadow = new DropShadow();
- dropShadow.setRadius(200.0);
- dropShadow.setColor(Color.ORANGE);
- dropShadow.setBlurType(BlurType.GAUSSIAN);
- test.getChildren().add(b5);
- test.setEffect(dropShadow);
-
-
-
- blockGrid.add(b1, 0, 0);
- blockGrid.add(b2, 1, 0);
- blockGrid.add(b3, 0, 1);
- blockGrid.add(b4, 1, 1);
- blockGrid.add(test, 1, 2);
-
- Button btn = new Button();
- btn.setText("Test");
- btn.setOnAction(new EventHandler<ActionEvent>()
- {
- @Override
- public void handle(ActionEvent event)
- {
- System.out.println("test");
- }
- });
-
- background.setLeft(btn);
-
- primaryStage.setScene(game);
- primaryStage.show();
-
- }
-} \ No newline at end of file
diff --git a/src/test/NoteTest.java b/src/test/NoteTest.java
deleted file mode 100644
index ce74d56..0000000
--- a/src/test/NoteTest.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*Name:
- *Date:
- *Period:
- *Teacher:
- *Description:
- */
-package test;
-import java.awt.*;
-
-public class NoteTest
-{
- private boolean failed = false;
- private int lane;
- private final int NOTESPEED = 1;
- private int yPos = SongPlayer.HEIGHT;
-
- public void gameTick() {
- if (!failed) {
- if (yPos > 0) {
- yPos -= NOTESPEED;
- }
- else {
- failed = true;
- }
- }
- }
-
- public boolean getFailed() {
- return failed;
- }
-
- public int getY() {
- return yPos;
- }
-}
diff --git a/src/test/SongPlayer.java b/src/test/SongPlayer.java
deleted file mode 100644
index 48f859d..0000000
--- a/src/test/SongPlayer.java
+++ /dev/null
@@ -1,97 +0,0 @@
-/*Name:
- *Date:
- *Period:
- *Teacher:
- *Description:
- */
-package test;
-
-import java.awt.*;
-import java.awt.event.*;
-import javax.swing.*;
-
-
-public class SongPlayer
-{
- public static final int HEIGHT = 650;
- public static final int LENGTH = 400;
-
-
- private final int BLENGTH = LENGTH/6;
- private final int BHEIGHT = HEIGHT/20;
- JFrame frame = new JFrame("Guitar Hero"); //creates the frame
-
-
- JButton d = new JButton("D"); //creates the four button lanes
- JButton f = new JButton("F");
- JButton h = new JButton("H");
- JButton j = new JButton("J");
-
-
- public void createAndShowGui() {
-
- d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); //makes the button bounds for each button
- f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- h.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
-
-
- frame.add(d); //adds the buttons to the frame
- frame.add(f);
- frame.add(h);
- frame.add(j);
-
- frame.setSize(LENGTH, HEIGHT); //sets the size of the frame
- frame.setLayout(null); //???
- frame.setVisible(true); //makes the frame visible
-
- KeyDetection dAction = new KeyDetection('d'); //creates an action for each char
- d.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('d'), "dPress"); //Input map and Action map setting
- d.getActionMap().put("dPress", dAction);
- d.setFocusable(false); //makes it so you can't highlight the button
-
- KeyDetection fAction = new KeyDetection('f');
- f.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('f'), "fPress");
- f.getActionMap().put("fPress", fAction);
- f.setFocusable(false);
-
- KeyDetection hAction = new KeyDetection('h');
- h.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('h'), "hPress");
- h.getActionMap().put("hPress", hAction);
- h.setFocusable(false);
-
- KeyDetection jAction = new KeyDetection('j');
- j.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke('j'), "jPress");
- j.getActionMap().put("jPress", jAction);
- j.setFocusable(false);
- }
-
- public void loop() {
- JButton note = new JButton();
- JButton test = new JButton();
- test.setBounds(200, 200, 100, 100);
- note.setBounds(BLENGTH, 0, BLENGTH, BHEIGHT);
- frame.add(note);
- frame.add(test);
-
- NoteTest a = new NoteTest();
- while (!a.getFailed()) {
- if (!a.getFailed()) {
- a.gameTick();
- note.setBounds(BLENGTH, HEIGHT-a.getY(), BLENGTH, BHEIGHT); //moves the note down every frame
- System.out.println(a.getFailed());
- //the computer runs too fast normally, force it to run at a certain fps
- try {
- Thread.sleep(2);
- } catch (InterruptedException e)
- {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- if (a.getFailed()) {
- frame.remove(note); //removes the note once its off the screen
- }
- }
- }
-}
diff --git a/src/test/SongPlayer2.java b/src/test/SongPlayer2.java
deleted file mode 100644
index ed6476d..0000000
--- a/src/test/SongPlayer2.java
+++ /dev/null
@@ -1,232 +0,0 @@
-/*Name: Guitar Hero Project
- *Description: Contains the main game loop for gameplay
- */
-package gui;
-
-import javafx.scene.control.Button;
-import javafx.scene.layout.HBox;
-import javafx.scene.layout.Pane;
-
-import java.util.*;
-
-import fallTest.NoteField;
-import fallTest.NoteInfo;
-import fallTest.Score;
-import fallTest.Timer;
-//test
-public class SongPlayer2 extends Pane
-{
- Timer time = new Timer();
-
- public static final int HEIGHT = 650;
- public static final int LENGTH = 400;
-
- private final int BLENGTH = LENGTH/7;
- private final int BHEIGHT = HEIGHT/20;
-
- Button d = new Button("D");
- Button f = new Button("F");
- Button space= new Button("...");
- Button j = new Button("J");
- Button k = new Button("K");
-
- Queue<NoteInfo> dSends = new LinkedList<NoteInfo>(); //Queue that dictates when to send the notes
- ArrayList<NoteField> dLane = new ArrayList<NoteField>(); //Array list containing all the notes currently on the field
- ArrayList<Block> dVis = new ArrayList<Block>(); //Array list containing the visual representations of the notes in lanes
-
- Queue<NoteInfo> fSends = new LinkedList<NoteInfo>();
- ArrayList<NoteField> fLane = new ArrayList<NoteField>();
- ArrayList<Block> fVis = new ArrayList<Block>();
-
- Queue<NoteInfo> spaceSends = new LinkedList<NoteInfo>();
- ArrayList<NoteField> spaceLane = new ArrayList<NoteField>();
- ArrayList<Block> spaceVis = new ArrayList<Block>();
-
- Queue<NoteInfo> jSends = new LinkedList<NoteInfo>();
- ArrayList<NoteField> jLane = new ArrayList<NoteField>();
- ArrayList<Block> jVis = new ArrayList<Block>();
-
- Queue<NoteInfo> kSends = new LinkedList<NoteInfo>();
- ArrayList<NoteField> kLane = new ArrayList<NoteField>();
- ArrayList<Block> kVis = new ArrayList<Block>();
-
- Score score = new Score();
-
- /**
- * Establishes what the chart for the song is going to look like
- */
- public void loadSong() {
- dSends.add(new NoteInfo(4000));
- dSends.add(new NoteInfo(4333));
- dSends.add(new NoteInfo(4666));
- fSends.add(new NoteInfo(5000));
- kSends.add(new NoteInfo(5500));
- spaceSends.add(new NoteInfo(6000));
- jSends.add(new NoteInfo(6000));
- jSends.add(new NoteInfo(6250));
- dSends.add(new NoteInfo(6500));
- jSends.add(new NoteInfo(6750));
- spaceSends.add(new NoteInfo(7000));
- fSends.add(new NoteInfo(7500));
- jSends.add(new NoteInfo(7750));
- spaceSends.add(new NoteInfo(8000));
- fSends.add(new NoteInfo(8500));
- jSends.add(new NoteInfo(8500));
- dSends.add(new NoteInfo(9000));
- spaceSends.add(new NoteInfo(9000));
- kSends.add(new NoteInfo(9000));
- spaceSends.add(new NoteInfo(9500));
-
- kSends.add(new NoteInfo(10000));
- dSends.add(new NoteInfo(10000));
- kSends.add(new NoteInfo(10333));
- fSends.add(new NoteInfo(10333));
- kSends.add(new NoteInfo(10666));
- spaceSends.add(new NoteInfo(10666));
- dSends.add(new NoteInfo(11000));
- spaceSends.add(new NoteInfo(11000));
- dSends.add(new NoteInfo(11333));
- jSends.add(new NoteInfo(11333));
- dSends.add(new NoteInfo(11666));
- kSends.add(new NoteInfo(11666));
- spaceSends.add(new NoteInfo(12000));
- }
-
-
- /**
- * Creates the GUI used to play the game
- */
- public SongPlayer2() {
-
- // d.setBounds(1*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT); //makes the button bounds for each button
- // f.setBounds(2*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- // space.setBounds(3*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- // j.setBounds(4*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- // k.setBounds(5*BLENGTH, (5*HEIGHT)/6, BLENGTH, BHEIGHT);
- // d.setFocusable(false); //makes it so you can't focus on the button
- // f.setFocusable(false);
- // space.setFocusable(false);
- // j.setFocusable(false);
- // k.setFocusable(false);
-
-
- HBox bottom = new HBox();
- bottom.getChildren().add(d); //adds the buttons to the frame
- bottom.getChildren().add(f);
- bottom.getChildren().add(space);
- bottom.getChildren().add(j);
- bottom.getChildren().add(k);
- super.getChildren().add(bottom);
- //frame.setSize(LENGTH, HEIGHT); //sets the size of the frame
- //frame.setLayout(null);
- //frame.setVisible(true); //makes the frame visible
-
-
- //while (true) { //TRY TO FIND A BETTER SOLUTION FOR THIS?? maybe something like sends.size() > 0 || lanes.size() > 0
-
- // update(d, dSends, dLane, dVis, 'd', "dPress", 1); //updates the provided lane
- // update(f, fSends, fLane, fVis, 'f', "fPress", 2);
- // update(space, spaceSends, spaceLane, spaceVis, ' ', "spacePress", 3);
- // update(j, jSends, jLane, jVis, 'j', "jPress", 4);
- // update(k, kSends, kLane, kVis, 'k', "kPress", 5);
-
- // frame.repaint(); //updates the visuals every frame
-
- // try {
- // Thread.sleep(10); //THIS IS PROBABLY NOT THE BEST WAY TO DO THIS
- // } catch (InterruptedException e)
- // {
- // e.printStackTrace();
- // }
- //}
- }
-
- /**
- * Updates a lane. An update involves:
- * Checking to see if a note needs to be sent down a lane
- * Checking to see if the user hit the button
- * Checking to see if any notes have moved past the lane
- * @param sends The sending queue for the given lane
- * @param lane The place where note information is stored for notes currently in that lane
- * @param vis The place where the visual representation for a note is stored in that lane
- * @param key The button on the keyboard corresponding to the button for the lane being updated
- * @param id The id for the action map
- * @param k The lane number
- */
- /*
- private void update(JButton button, Queue<NoteInfo> sends, ArrayList<NoteField> lane, ArrayList<JButton> vis, char key, String id, int k) {
- if (!sends.isEmpty() && sends.peek().getTime()-time.time()<3) { //checks if any notes in the queue need to be sent at this time
- lane.add(new NoteField()); //adds that note's information to the lane list
-
- vis.add(new JButton()); //creates a visual representation of that note in the visualizer list
- frame.add(vis.get(vis.size()-1));
-
- sends.remove(); //removes the note just sent from the sending queue
- }
-
- if (lane.size() > 0) { //if there are any notes in the lanes, tests for a button press
- button.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(key), id); //Input map and Action map setting
- button.getActionMap().put(id, new AbstractAction() { //Defines what happens when the proper button is pressed
- public void actionPerformed(ActionEvent e)
- {
- if (lane.size() > 0) {
- int i = getClosestNote(lane);
- int dist = (int)Math.abs(lane.get(i).goalDistance());
-
- lane.remove(i); //removes the notes and visual representation from the playing field when the button is pressed
- frame.remove(vis.get(i));
- vis.remove(i);
-
- if (dist > 2*BHEIGHT) { //Determines what to add to the score depending on the proximity of the note
- score.miss();
- }
- else if (dist > BHEIGHT) {
- score.combo();
- score.close();
- }
- else {
- score.combo();
- score.perfect();
- }
-
- System.out.println("Score: " + score.getScore() + " Combo: " + score.getCombo());
- }
- }
- });
- }
-
- for (int i=0; i<lane.size(); i++) { //goes through every note on the field
- lane.get(i).gameTick(); //moves every note down
- vis.get(i).setBounds(k*BLENGTH, HEIGHT-lane.get(i).getY(), BLENGTH, BHEIGHT);
-
- if (lane.size() > 0 && lane.get(i).getFailed()) { //if the note has passed into the fail boundary, removes the note from the field
- score.miss();
- System.out.println(score.getScore() + " Combo: " + score.getCombo());
-
-
- lane.remove(i);
- frame.remove(vis.get(i));
- vis.remove(i);
-
- i--;
- }
- }
- }
-
- /**
- * Finds the note closest to the goal
- * @return the location in the array list of the closest note
-
- private int getClosestNote(ArrayList<NoteField> searchLane) {
- int pos = 0;
-
- for (int i=0; i<searchLane.size(); i++) {
- if (Math.abs(searchLane.get(i).goalDistance()) < Math.abs(searchLane.get(pos).goalDistance())) {
- pos = i;
- }
- }
-
- return pos;
- }
- */
-}
diff --git a/src/test/Table.java b/src/test/Table.java
deleted file mode 100644
index 5571ebd..0000000
--- a/src/test/Table.java
+++ /dev/null
@@ -1,112 +0,0 @@
-package test;
-
-import javafx.application.Application;
-import javafx.beans.property.SimpleStringProperty;
-import javafx.collections.FXCollections;
-import javafx.collections.ObservableList;
-import javafx.geometry.Insets;
-import javafx.scene.Group;
-import javafx.scene.Scene;
-import javafx.scene.control.Label;
-import javafx.scene.control.TableColumn;
-import javafx.scene.control.TableView;
-import javafx.scene.control.TextField;
-import javafx.scene.control.cell.PropertyValueFactory;
-import javafx.scene.layout.VBox;
-import javafx.scene.text.Font;
-import javafx.stage.Stage;
-
-public class Table extends Application {
-
- private TableView<Person> table = new TableView<Person>();
- private final ObservableList<Person> data =
- FXCollections.observableArrayList(
- new Person("Jacob", "Smith", "jacob.smith@example.com"),
- new Person("Isabella", "Johnson", "isabella.johnson@example.com"),
- new Person("Ethan", "Williams", "ethan.williams@example.com"),
- new Person("Emma", "Jones", "emma.jones@example.com"),
- new Person("Michael", "Brown", "michael.brown@example.com")
- );
-
- public static void main(String[] args) {
- launch(args);
- }
-
- @Override
- public void start(Stage stage) {
- Scene scene = new Scene(new Group());
- stage.setTitle("Table View Sample");
- stage.setWidth(450);
- stage.setHeight(500);
-
- final Label label = new Label("Address Book");
- label.setFont(new Font("Arial", 20));
-
- table.setEditable(true);
-
- TableColumn firstNameCol = new TableColumn("First Name");
- firstNameCol.setMinWidth(100);
- firstNameCol.setCellValueFactory(
- new PropertyValueFactory<Person, String>("firstName"));
-
- TableColumn lastNameCol = new TableColumn("Last Name");
- lastNameCol.setMinWidth(100);
- lastNameCol.setCellValueFactory(
- new PropertyValueFactory<Person, String>("lastName"));
-
- TableColumn emailCol = new TableColumn("Email");
- emailCol.setMinWidth(200);
- emailCol.setCellValueFactory(
- new PropertyValueFactory<Person, String>("email"));
-
- table.setItems(data);
- table.getColumns().addAll(firstNameCol, lastNameCol, emailCol);
-
- final VBox vbox = new VBox();
- vbox.setSpacing(5);
- vbox.setPadding(new Insets(10, 0, 0, 10));
- vbox.getChildren().addAll(label, table);
-
- ((Group) scene.getRoot()).getChildren().addAll(vbox);
-
- stage.setScene(scene);
- stage.show();
- }
-
- public static class Person {
-
- private final SimpleStringProperty firstName;
- private final SimpleStringProperty lastName;
- private final SimpleStringProperty email;
-
- private Person(String fName, String lName, String email) {
- this.firstName = new SimpleStringProperty(fName);
- this.lastName = new SimpleStringProperty(lName);
- this.email = new SimpleStringProperty(email);
- }
-
- public String getFirstName() {
- return firstName.get();
- }
-
- public void setFirstName(String fName) {
- firstName.set(fName);
- }
-
- public String getLastName() {
- return lastName.get();
- }
-
- public void setLastName(String fName) {
- lastName.set(fName);
- }
-
- public String getEmail() {
- return email.get();
- }
-
- public void setEmail(String fName) {
- email.set(fName);
- }
- }
-} \ No newline at end of file
diff --git a/src/test/focusTest.java b/src/test/focusTest.java
deleted file mode 100644
index bc337da..0000000
--- a/src/test/focusTest.java
+++ /dev/null
@@ -1,46 +0,0 @@
-package test;
-
-import javafx.application.Application;
-import javafx.geometry.Pos;
-import javafx.scene.Scene;
-import javafx.scene.control.ToggleButton;
-import javafx.scene.layout.HBox;
-import javafx.scene.layout.VBox;
-import javafx.stage.Stage;
-
-public class focusTest extends Application {
-
- public static void main(String[] args)
- {
- launch(args);
- }
-
- @Override
- public void start(Stage primaryStage) throws Exception
- {
- VBox root = new VBox();
- root.setAlignment(Pos.CENTER);
- root.setSpacing(20);
- Scene sc = new Scene(root, 500, 500);
- primaryStage.setScene(sc);
- primaryStage.show();
-
-
- ToggleButton btn1 = new ToggleButton("Button 1");
- ToggleButton btn2 = new ToggleButton("Button 2");
- ToggleButton btn3 = new ToggleButton("Button 3");
- ToggleButton btn4 = new ToggleButton("Button 4");
-
- HBox hb1 = new HBox();
- hb1.setAlignment(Pos.CENTER);
- hb1.getChildren().addAll(btn1, btn2);
-
- HBox hb2 = new HBox();
- hb2.setAlignment(Pos.CENTER);
- hb2.getChildren().addAll(btn3, btn4);
-
- root.getChildren().addAll(hb1, hb2);
-
- hb1.requestFocus();
- }
-}