diff options
author | unknown <Adam Martindale@.(none)> | 2011-09-16 12:08:24 +0100 |
---|---|---|
committer | unknown <Adam Martindale@.(none)> | 2011-09-16 12:08:24 +0100 |
commit | 8721d9014c86909910fbc9031e0c9e7668e49826 (patch) | |
tree | 4b50e0c60ba1511cacdf1c9b9f5d33dab5bee57b /PunchingBag | |
parent | 4fa115f2270fde1acfb9da36e8b47166190f03da (diff) | |
download | punchingbag-8721d9014c86909910fbc9031e0c9e7668e49826.tar punchingbag-8721d9014c86909910fbc9031e0c9e7668e49826.tar.gz |
Added idle noise
Diffstat (limited to 'PunchingBag')
-rw-r--r-- | PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java | 6 | ||||
-rw-r--r-- | PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java | 16 |
2 files changed, 18 insertions, 4 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java index 4acb2d0..e03c4e6 100644 --- a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java +++ b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBagGUI.java @@ -64,7 +64,7 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, Debug, Menu }; - Mode currentMode = Mode.Menu; + Mode currentMode = Mode.Debug; JFrame frame; @@ -146,8 +146,8 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener, programOptionsPanel.add(new JButton("Debug")); frame.add(bagDebugingPanel); - frame.add(new DisplayPanel(), BorderLayout.CENTER); - frame.add(programOptionsPanel, BorderLayout.SOUTH); + //frame.add(new DisplayPanel(), BorderLayout.CENTER); + //frame.add(programOptionsPanel, BorderLayout.SOUTH); setMode(currentMode); diff --git a/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java b/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java index a8d32ff..b2d96a5 100644 --- a/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java +++ b/PunchingBag/src/uk/ac/open/punchingbag/examples/SimpleKeyboard.java @@ -1,6 +1,7 @@ package uk.ac.open.punchingbag.examples; import java.awt.Color; +import java.awt.Rectangle; import java.io.File; import java.io.IOException; @@ -15,7 +16,7 @@ import uk.ac.open.punchingbag.ButtonListener; import uk.ac.open.punchingbag.Contact; import uk.ac.open.punchingbag.PunchingBag; -public class SimpleKeyboard implements ButtonListener { +public class SimpleKeyboard implements ButtonListener, Runnable { String soundDir = System.getProperty("user.dir") + System.getProperty("file.separator"); @@ -26,6 +27,7 @@ public class SimpleKeyboard implements ButtonListener { new File(soundDir + "G5.wav") }; static PunchingBag bag = PunchingBag.getBag(); + long lastActionTime = System.currentTimeMillis(); public static void main(String[] args) { new SimpleKeyboard(); @@ -39,9 +41,11 @@ public class SimpleKeyboard implements ButtonListener { // TODO Auto-generated catch block e.printStackTrace(); } + new Thread (this).start(); } public void buttonPressed(int x, int y) { + lastActionTime = System.currentTimeMillis(); System.out.println("Button Pressed: " + x + " " + y); if (y < 3) { bag.fillRect(0, 0, 9, 4, Color.red, 500); @@ -90,5 +94,15 @@ public class SimpleKeyboard implements ButtonListener { } + @Override + public void run() { + while (true) { + if ((System.currentTimeMillis() - lastActionTime) > 4000) { + bag.noise(new Rectangle(0, 0, 9, 20)); + } + } + + } + } |