aboutsummaryrefslogtreecommitdiff
path: root/apcs/SongPlayer.java
diff options
context:
space:
mode:
authorsowgro <tpoke.ferrari@gmail.com>2023-05-03 22:50:43 -0400
committersowgro <tpoke.ferrari@gmail.com>2023-05-03 22:50:43 -0400
commit95a82dc15a17a3fe16d34a1cc3c2ec5b46129c73 (patch)
treeaf87cffaf5009a055351a1210723ca579e6d2bcc /apcs/SongPlayer.java
parent291cf3bbfbd316f6acdb6d686470113ab91f53b6 (diff)
downloadNPEhero-95a82dc15a17a3fe16d34a1cc3c2ec5b46129c73.tar.gz
NPEhero-95a82dc15a17a3fe16d34a1cc3c2ec5b46129c73.tar.bz2
NPEhero-95a82dc15a17a3fe16d34a1cc3c2ec5b46129c73.zip
more file management
Diffstat (limited to 'apcs/SongPlayer.java')
-rw-r--r--apcs/SongPlayer.java43
1 files changed, 34 insertions, 9 deletions
diff --git a/apcs/SongPlayer.java b/apcs/SongPlayer.java
index f17534b..50e06aa 100644
--- a/apcs/SongPlayer.java
+++ b/apcs/SongPlayer.java
@@ -4,7 +4,7 @@
*Teacher:
*Description:
*/
-package apcs;
+package cs;
import java.awt.*;
import java.awt.event.*;
@@ -16,16 +16,19 @@ 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() {
- 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");
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);
@@ -64,9 +67,31 @@ public class SongPlayer
}
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 (true) {
- a.gameTick();
+ 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
+ }
}
}
}