aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Baines <cbaines8@gmail.com>2011-09-13 16:27:45 +0100
committerChristopher Baines <cbaines8@gmail.com>2011-09-13 16:27:45 +0100
commitca272fe905c2adacc353f6711417669f240e8faa (patch)
tree3e22238617cabe5e98dce2e0c8962504441a3221
parent132db792e5e0f636318a9dacb8efa783c1ade085 (diff)
downloadpunchingbag-ca272fe905c2adacc353f6711417669f240e8faa.tar
punchingbag-ca272fe905c2adacc353f6711417669f240e8faa.tar.gz
Improved for Ode to Joy.
-rw-r--r--PunchingBag/src/PunchingBagGUI.java39
1 files changed, 19 insertions, 20 deletions
diff --git a/PunchingBag/src/PunchingBagGUI.java b/PunchingBag/src/PunchingBagGUI.java
index ef34459..5db11ef 100644
--- a/PunchingBag/src/PunchingBagGUI.java
+++ b/PunchingBag/src/PunchingBagGUI.java
@@ -61,9 +61,10 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
String soundDir = System.getProperty("user.dir")
+ System.getProperty("file.separator");
- File[] keys = { new File(soundDir + "C5.wav"),
- new File(soundDir + "D5.wav"), new File(soundDir + "E5.wav"),
- new File(soundDir + "F5.wav"), new File(soundDir + "G5.wav") };
+ File[] keys = { new File(soundDir + "G4.wav"),
+ new File(soundDir + "C5.wav"), new File(soundDir + "D5.wav"),
+ new File(soundDir + "E5.wav"), new File(soundDir + "F5.wav"),
+ new File(soundDir + "G5.wav") };
static PunchingBag bag = new PunchingBag();
@@ -76,12 +77,10 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
PunchingBagGUI() throws InterruptedException {
- //System.out.println(AudioSystem.getMixerInfo()[0].getName());
- //System.out.println(AudioSystem.getMixerInfo()[0].getDescription());
- //Mixer mix = AudioSystem.getMixer(AudioSystem.getMixerInfo()[0]);
+ // System.out.println(AudioSystem.getMixerInfo()[0].getName());
+ // System.out.println(AudioSystem.getMixerInfo()[0].getDescription());
+ // Mixer mix = AudioSystem.getMixer(AudioSystem.getMixerInfo()[0]);
-
-
bag.connectToArduinos();
frame = new JFrame("Punching Bag GUI");
@@ -116,7 +115,7 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
// frame.pack();
}
-
+
void playKey(int key) {
try {
AudioInputStream sound = AudioSystem.getAudioInputStream(keys[key]);
@@ -594,29 +593,29 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
// bag.squareExpand(x,y, 16, PunchingBag.Colour.Red);
// Ode to Joy
- //bag.rect(0, 0, 9, 4, PunchingBag.Colour.Red);
- //bag.rect(0, 4, 9, 4, PunchingBag.Colour.Red);
- //bag.rect(0, 8, 9, 4, PunchingBag.Colour.Red);
- //bag.rect(0, 12, 9, 4, PunchingBag.Colour.Red);
- //bag.rect(0, 16, 9, 4, PunchingBag.Colour.Red);
+ // bag.rect(0, 0, 9, 4, PunchingBag.Colour.Red);
+ // bag.rect(0, 4, 9, 4, PunchingBag.Colour.Red);
+ // bag.rect(0, 8, 9, 4, PunchingBag.Colour.Red);
+ // bag.rect(0, 12, 9, 4, PunchingBag.Colour.Red);
+ // bag.rect(0, 16, 9, 4, PunchingBag.Colour.Red);
if (y < 3) {
bag.fillRect(0, 0, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(0);
+ playKey(5);
} else if (y < 6) {
bag.fillRect(0, 3, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(1);
+ playKey(4);
} else if (y < 9) {
bag.fillRect(0, 6, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(2);
+ playKey(3);
} else if (y < 12) {
bag.fillRect(0, 9, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(3);
+ playKey(2);
} else if (y < 15) {
bag.fillRect(0, 12, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(4);
+ playKey(1);
} else {
bag.fillRect(0, 15, 9, 4, PunchingBag.Colour.Red, 500);
- playKey(4);
+ playKey(0);
}
}