From ca272fe905c2adacc353f6711417669f240e8faa Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Tue, 13 Sep 2011 16:27:45 +0100 Subject: Improved for Ode to Joy. --- PunchingBag/src/PunchingBagGUI.java | 39 ++++++++++++++++++------------------- 1 file 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); } } -- cgit v1.2.3