diff options
| -rw-r--r-- | .classpath | 18 | ||||
| -rw-r--r-- | src/assets/BookBetrayal.mp3 | bin | 0 -> 5624404 bytes | |||
| -rw-r--r-- | src/fallTest/Block.java | 27 | ||||
| -rw-r--r-- | src/fallTest/Driver.java | 45 | ||||
| -rw-r--r-- | src/fallTest/Hbox.java | 5 | ||||
| -rw-r--r-- | src/fallTest/Level.java | 106 | ||||
| -rw-r--r-- | src/fallTest/NoteNode.java | 19 | ||||
| -rw-r--r-- | src/fallTest/TButton.java | 27 | ||||
| -rw-r--r-- | src/fallTest/newSongPlayer.java | 130 | ||||
| -rw-r--r-- | src/gui/JsonReader.java | 5 | ||||
| -rw-r--r-- | src/gui/JsonStructure.java | 5 | ||||
| -rw-r--r-- | src/gui/JsonValue.java | 9 | ||||
| -rw-r--r-- | src/gui/JsonWriter.java | 5 | ||||
| -rw-r--r-- | src/gui/SettingsController.java | 5 | ||||
| -rw-r--r-- | src/gui/SongPlayer2.java | 232 | 
15 files changed, 623 insertions, 15 deletions
| @@ -1,18 +1,18 @@  <?xml version="1.0" encoding="UTF-8"?>
  <classpath>
  	<classpathentry kind="src" path="src"/>
 -	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
 +	<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
  		<attributes>
  			<attribute name="module" value="true"/>
  		</attributes>
  	</classpathentry>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.base.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.controls.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.fxml.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.graphics.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.media.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.swing.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx.web.jar"/>
 -	<classpathentry kind="lib" path="lib/windows/lib/javafx-swt.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.base.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.controls.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.fxml.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.graphics.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.media.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.swing.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx.web.jar"/>
 +	<classpathentry exported="true" kind="lib" path="lib/windows/lib/javafx-swt.jar"/>
  	<classpathentry kind="output" path="bin"/>
  </classpath>
 diff --git a/src/assets/BookBetrayal.mp3 b/src/assets/BookBetrayal.mp3Binary files differ new file mode 100644 index 0000000..cf274a6 --- /dev/null +++ b/src/assets/BookBetrayal.mp3 diff --git a/src/fallTest/Block.java b/src/fallTest/Block.java new file mode 100644 index 0000000..ab2f902 --- /dev/null +++ b/src/fallTest/Block.java @@ -0,0 +1,27 @@ +//glowing block of color c (jfx node) + +package fallTest; + +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/fallTest/Driver.java b/src/fallTest/Driver.java index 0ad60f0..3bc7c25 100644 --- a/src/fallTest/Driver.java +++ b/src/fallTest/Driver.java @@ -6,16 +6,49 @@   */  package fallTest; +import javafx.application.*; +import javafx.geometry.Side; +import javafx.scene.Scene; +import javafx.scene.image.Image; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.Pane; +import javafx.stage.Stage; -public class Driver +public class Driver extends Application  { +    static Pane primaryPane = new Pane(); +      public static void main(String[] args)      { -        // TODO Auto-generated method stub -        SongPlayer g = new SongPlayer(); -        g.loadSong(); -        g.createAndShowGui(); -    } +        launch(args); +    } +	@Override +	public void start(Stage primaryStage) throws Exception { +		Scene primaryScene = new Scene(primaryPane, 800, 600); +        primaryScene.getStylesheets().add("gui/style.css"); +        primaryStage.setScene(primaryScene); +        newSongPlayer player = new newSongPlayer(); +        primaryStage.setTitle("TEST"); +        primaryPane.getChildren().add(player);      +        setBackground("assets/water.png");    +        player.init(); +        primaryStage.show(); +	} +	 +	  public static void setBackground(String url) +      { +          primaryPane.setBackground(new Background( +              new BackgroundImage( +                      new Image(url), +                      BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, +                      new BackgroundPosition(Side.LEFT, 0, true, Side.BOTTOM, 0, true), +                      new BackgroundSize(BackgroundSize.AUTO, BackgroundSize.AUTO, true, true, false, true) +              ))); +      }  } diff --git a/src/fallTest/Hbox.java b/src/fallTest/Hbox.java new file mode 100644 index 0000000..a7a97a7 --- /dev/null +++ b/src/fallTest/Hbox.java @@ -0,0 +1,5 @@ +package fallTest; + +public class Hbox { + +} diff --git a/src/fallTest/Level.java b/src/fallTest/Level.java new file mode 100644 index 0000000..71ee0a8 --- /dev/null +++ b/src/fallTest/Level.java @@ -0,0 +1,106 @@ +package fallTest; + +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.AnchorPane; +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.layout.StackPane; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Font; +import javafx.scene.text.FontWeight; +import javafx.scene.text.Text; +import javafx.stage.Stage; +  +// will eventually extend pane +public class Level extends Pane { +    +  +    public Level() { + +        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); + +        +         +    } +}
\ No newline at end of file diff --git a/src/fallTest/NoteNode.java b/src/fallTest/NoteNode.java new file mode 100644 index 0000000..c24e10f --- /dev/null +++ b/src/fallTest/NoteNode.java @@ -0,0 +1,19 @@ +package fallTest;
 +
 +import javafx.animation.*;
 +import javafx.util.Duration;
 +
 +public class NoteNode {
 +	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();
 +		anim.setCycleCount(1);
 +		anim.setAutoReverse(false);
 +		anim.play();
 +	}
 +}
 diff --git a/src/fallTest/TButton.java b/src/fallTest/TButton.java new file mode 100644 index 0000000..d18771f --- /dev/null +++ b/src/fallTest/TButton.java @@ -0,0 +1,27 @@ +//glowing block of color c (jfx node) + +package fallTest; + +import javafx.scene.effect.BlurType; +import javafx.scene.effect.DropShadow; +import javafx.scene.paint.Color; +import javafx.scene.shape.Rectangle; +import javafx.scene.text.Text; +import javafx.scene.paint.*; + +public class TButton extends Rectangle +{ +    public TButton(Color c, double a, double b, int r) +    { +        super(); +         +        Color newCol = new Color(c.darker().getRed(), c.darker().getGreen(), c.darker().getBlue(), 0.25); +        super.setFill(newCol); +        super.setWidth(a); +        super.setHeight(b); +        super.setArcHeight(r); +        super.setArcWidth(r); +        super.setStroke(c); +        super.setStrokeWidth(5); +    } +}
\ No newline at end of file diff --git a/src/fallTest/newSongPlayer.java b/src/fallTest/newSongPlayer.java new file mode 100644 index 0000000..ff96d63 --- /dev/null +++ b/src/fallTest/newSongPlayer.java @@ -0,0 +1,130 @@ +package fallTest;
 +
 +import javafx.event.EventHandler;
 +
 +import java.awt.Insets;
 +
 +import javafx.event.*;
 +import javafx.event.ActionEvent;
 +import javafx.geometry.Pos;
 +import javafx.scene.control.Button;
 +import javafx.scene.effect.BlurType;
 +import javafx.scene.effect.DropShadow;
 +import javafx.scene.input.KeyCode;
 +import javafx.scene.layout.Border;
 +import javafx.scene.layout.BorderStroke;
 +import javafx.scene.layout.BorderStrokeStyle;
 +import javafx.scene.layout.BorderWidths;
 +import javafx.scene.layout.CornerRadii;
 +import javafx.scene.layout.HBox;
 +import javafx.scene.layout.Pane;
 +import javafx.scene.layout.StackPane;
 +import javafx.scene.layout.VBox;
 +import javafx.scene.paint.Color;
 +import javafx.scene.shape.Rectangle;
 +import javafx.scene.text.Font;
 +import javafx.scene.text.Text;
 +
 +public class newSongPlayer extends Pane
 +{
 +	public void init() {
 +		Rectangle field = new Rectangle(50, 50, new Color(0, 0, 0, 0.7));
 +		field.heightProperty().bind(this.getScene().getWindow().heightProperty().multiply(0.95));
 +		field.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(2.).add(50));
 +		
 +		TButton dButton = new TButton(Color.RED, 50, 50, 5);
 +		dButton.heightProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		dButton.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		dButton.arcHeightProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		dButton.arcWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		dButton.strokeWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(210));
 +		//Text dButtonText = new Text("D");
 +		dButton.setOnKeyPressed(e -> { 
 +			if (e.getCode() == KeyCode.D) {
 +				System.out.println("D");
 +			}
 +		});
 +		
 +		TButton fButton = new TButton(Color.BLUE, 50, 50, 5);
 +		fButton.heightProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		fButton.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		fButton.arcHeightProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		fButton.arcWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		fButton.strokeWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(210));
 +		fButton.setOnKeyPressed(e -> { 
 +			if (e.getCode() == KeyCode.F) {
 +				System.out.println("F");
 +			}
 +		});
 +		
 +		TButton sButton = new TButton(Color.GREEN, 50, 50, 5);
 +		sButton.heightProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		sButton.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		sButton.arcHeightProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		sButton.arcWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		sButton.strokeWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(210));
 +		sButton.setOnKeyPressed(e -> { 
 +			if (e.getCode() == KeyCode.SPACE) {
 +				System.out.println("SPC");
 +			}
 +		});
 +		
 +		TButton jButton = new TButton(Color.PURPLE, 50, 50, 5);
 +		jButton.heightProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		jButton.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		jButton.arcHeightProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		jButton.arcWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		jButton.strokeWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(210));
 +		jButton.setOnKeyPressed(e -> { 
 +			if (e.getCode() == KeyCode.J) {
 +				System.out.println("J");
 +			}
 +		});
 +		
 +		TButton kButton = new TButton(Color.YELLOW, 50, 50, 5);
 +		kButton.heightProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		kButton.widthProperty().bind(this.getScene().getWindow().widthProperty().divide(12));
 +		kButton.arcHeightProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		kButton.arcWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(50));
 +		kButton.strokeWidthProperty().bind(this.getScene().getWindow().widthProperty().divide(210));
 +		kButton.setOnKeyPressed(e -> { 
 +			if (e.getCode() == KeyCode.K) {
 +				System.out.println("K");
 +			}
 +		});
 +		
 +		//StackPane dButtonComplete = new StackPane();
 +		//dButtonComplete.getChildren().addAll(dButtonText, dButton);
 +		
 +		HBox buttonBox = new HBox();
 +		
 +		buttonBox.setStyle("-fx-padding: 0;" + "-fx-border-style: solid inside;"
 +		        + "-fx-border-width: 0;" + "-fx-border-insets: 20;"
 +		        + "-fx-border-radius: 0;" + "-fx-border-color: black;"
 +		        + "-fx-background-color: black;" + "-fx-opacity: 0.67;");
 +		buttonBox.setAlignment(Pos.CENTER);
 +	    buttonBox.getChildren().addAll(dButton, fButton, sButton, jButton, kButton);
 +	    buttonBox.setSpacing(10);
 +	    
 +	    VBox polish = new VBox();
 +	    polish.prefHeightProperty().bind(this.getScene().heightProperty());
 +	    polish.getChildren().addAll(field);
 +	    polish.setAlignment(Pos.TOP_CENTER);
 +	    
 +	    VBox place = new VBox();
 +		place.prefWidthProperty().bind(this.getScene().widthProperty());
 +		place.prefHeightProperty().bind(this.getScene().heightProperty());
 +	    //root.setStyle("-fx-padding: 0;" + "-fx-border-style: solid inside;"
 +		//        + "-fx-border-width: 2;" + "-fx-border-insets: 0;"
 +		//        + "-fx-border-radius: 2;" + "-fx-border-color: red;");
 +	    place.setAlignment(Pos.BOTTOM_CENTER);
 +	    place.getChildren().addAll(buttonBox);
 +	    place.setSpacing(10);
 +	    
 +	    StackPane root = new StackPane();
 +	    root.getChildren().addAll(polish, place);
 +	    
 +        super.getChildren().add(root);
 +        
 +	}
 +}
 diff --git a/src/gui/JsonReader.java b/src/gui/JsonReader.java new file mode 100644 index 0000000..b1da06f --- /dev/null +++ b/src/gui/JsonReader.java @@ -0,0 +1,5 @@ +package gui;
 +
 +public interface JsonReader {
 +
 +}
 diff --git a/src/gui/JsonStructure.java b/src/gui/JsonStructure.java new file mode 100644 index 0000000..1ea2fa1 --- /dev/null +++ b/src/gui/JsonStructure.java @@ -0,0 +1,5 @@ +package gui;
 +
 +public interface JsonStructure {
 +
 +}
 diff --git a/src/gui/JsonValue.java b/src/gui/JsonValue.java new file mode 100644 index 0000000..e91f45b --- /dev/null +++ b/src/gui/JsonValue.java @@ -0,0 +1,9 @@ +package gui;
 +
 +public interface JsonValue 
 +{
 +	static JsonValue.ValueType getValueType() 
 +	{
 +		return null;
 +	}
 +}
 diff --git a/src/gui/JsonWriter.java b/src/gui/JsonWriter.java new file mode 100644 index 0000000..04fae8e --- /dev/null +++ b/src/gui/JsonWriter.java @@ -0,0 +1,5 @@ +package gui;
 +
 +public interface JsonWriter {
 +
 +}
 diff --git a/src/gui/SettingsController.java b/src/gui/SettingsController.java new file mode 100644 index 0000000..8898dc3 --- /dev/null +++ b/src/gui/SettingsController.java @@ -0,0 +1,5 @@ +package gui;
 +
 +public class SettingsController {
 +
 +}
 diff --git a/src/gui/SongPlayer2.java b/src/gui/SongPlayer2.java new file mode 100644 index 0000000..ed6476d --- /dev/null +++ b/src/gui/SongPlayer2.java @@ -0,0 +1,232 @@ +/*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; +    } +    */ +} | 
