aboutsummaryrefslogtreecommitdiff
path: root/PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java
diff options
context:
space:
mode:
Diffstat (limited to 'PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java')
-rw-r--r--PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java31
1 files changed, 29 insertions, 2 deletions
diff --git a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java
index e4e0c5e..6582fba 100644
--- a/PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java
+++ b/PunchingBag/src/uk/ac/open/punchingbag/PunchingBag.java
@@ -175,7 +175,7 @@ public class PunchingBag implements Runnable {
* Private constructor, starts the run method.
*/
private PunchingBag() {
- loadConfig();
+ //loadConfig();
Thread bagControlThread = new Thread(this);
bagControlThread.setPriority(Thread.MAX_PRIORITY);
bagControlThread.start();
@@ -233,6 +233,7 @@ public class PunchingBag implements Runnable {
* the <code>ButtonListener</code> to be added
*/
public void addButtonListener(ButtonListener l) {
+ System.out.println(l.toString() + " added as button listener");
buttonListenerList.add(ButtonListener.class, l);
}
@@ -370,6 +371,21 @@ public class PunchingBag implements Runnable {
public void fillRect(int x, int y, int width, int height, Color colour, long time) {
runningEffects.add(new FillRect(x, y, width, height, colour, time));
}
+
+ /**
+ * This should fill in a rectangle
+ *
+ * @param x
+ * The x coordinate of the top right of the rectangle
+ * @param y
+ * The y coordinate of the top right of the
+ * @param width
+ * @param height
+ * @param colour
+ */
+ public void fillRect(int x, int y, int width, int height, Color colour) {
+ runningEffects.add(new FillRect(x, y, width, height, colour));
+ }
/**
* @param x
@@ -468,10 +484,19 @@ public class PunchingBag implements Runnable {
this.colour = colour;
this.time = System.currentTimeMillis() + time;
}
+
+ public FillRect(int x, int y, int width, int height, Color colour) {
+ this.x = x;
+ this.y = y;
+ this.width = width;
+ this.height = height;
+ this.colour = colour;
+ this.time = -1;
+ }
public void draw() {
fillRectInternal(x, y, width, height, colour);
- if (System.currentTimeMillis() >= time) {
+ if (time != -1 && System.currentTimeMillis() >= time) {
stop();
}
}
@@ -1164,10 +1189,12 @@ public class PunchingBag implements Runnable {
if (buttonsChanged) {
ButtonListener[] buttonListeners = buttonListenerList.getListeners(ButtonListener.class);
+ //System.out.println(buttonListenerList.getListenerCount() + " button listeners");
for (int i = 0; i < buttonListenerList.getListenerCount(); i++) {
for (int x = 0; x < buttonWidth; x++) {
for (int y = 0; y < buttonHeight; y++) {
if (buttons[x][y]) {
+ System.out.println(" x " + x + " y " + y + " is pressed");
buttonListeners[i].buttonPressed(x, y);
buttonListeners[i].contact(new Contact(System.currentTimeMillis(), x, y, bottomAccelX));
}