From f0b65b04817e229ea6798bfcc2b1cf783fcb3717 Mon Sep 17 00:00:00 2001 From: Tyler Ferrari Date: Tue, 2 May 2023 15:53:46 +0000 Subject: Moves files into apcs package and fix refrences --- KeyDetection.java | 27 ---------------- SongPlayer.java | 72 ------------------------------------------ apcs/KeyDetection.java | 27 ++++++++++++++++ apcs/ShortAudioFilePlayer.java | 2 +- apcs/SongPlayer.java | 72 ++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 100 insertions(+), 100 deletions(-) delete mode 100644 KeyDetection.java delete mode 100644 SongPlayer.java create mode 100644 apcs/KeyDetection.java create mode 100644 apcs/SongPlayer.java diff --git a/KeyDetection.java b/KeyDetection.java deleted file mode 100644 index 429665a..0000000 --- a/KeyDetection.java +++ /dev/null @@ -1,27 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package cs; - -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/SongPlayer.java b/SongPlayer.java deleted file mode 100644 index 609e7c5..0000000 --- a/SongPlayer.java +++ /dev/null @@ -1,72 +0,0 @@ -/*Name: - *Date: - *Period: - *Teacher: - *Description: - */ -package cs; - -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; - - 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); - 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() { - NoteTest a = new NoteTest(); - while (true) { - a.gameTick(); - } - } -} diff --git a/apcs/KeyDetection.java b/apcs/KeyDetection.java new file mode 100644 index 0000000..9fc9db6 --- /dev/null +++ b/apcs/KeyDetection.java @@ -0,0 +1,27 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package apcs; + +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/apcs/ShortAudioFilePlayer.java b/apcs/ShortAudioFilePlayer.java index 5d9a381..0a03c9c 100644 --- a/apcs/ShortAudioFilePlayer.java +++ b/apcs/ShortAudioFilePlayer.java @@ -1,4 +1,4 @@ -package test; +package apcs; //Java program to play audio files. imports file scanning and various //methods from the java audio class in order to do so. import java.io.File; diff --git a/apcs/SongPlayer.java b/apcs/SongPlayer.java new file mode 100644 index 0000000..f17534b --- /dev/null +++ b/apcs/SongPlayer.java @@ -0,0 +1,72 @@ +/*Name: + *Date: + *Period: + *Teacher: + *Description: + */ +package apcs; + +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; + + 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); + 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() { + NoteTest a = new NoteTest(); + while (true) { + a.gameTick(); + } + } +} -- cgit v1.2.3