aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorunknown <Adam Martindale@.(none)>2011-09-12 13:03:58 +0100
committerunknown <Adam Martindale@.(none)>2011-09-12 13:03:58 +0100
commitf03e95a0a1f178c3023f2f8c677de7a4ca9a2f67 (patch)
treeda4e6c79982b79c390a6e05b914e22614d4c6134
parent188baf1e88e38e46c98b709f345969e67221d6f3 (diff)
downloadpunchingbag-f03e95a0a1f178c3023f2f8c677de7a4ca9a2f67.tar
punchingbag-f03e95a0a1f178c3023f2f8c677de7a4ca9a2f67.tar.gz
Testing of rectangle classes.
-rw-r--r--PunchingBag/src/PunchingBag.java35
-rw-r--r--PunchingBag/src/PunchingBagGUI.java6
2 files changed, 38 insertions, 3 deletions
diff --git a/PunchingBag/src/PunchingBag.java b/PunchingBag/src/PunchingBag.java
index 289405e..3a364ac 100644
--- a/PunchingBag/src/PunchingBag.java
+++ b/PunchingBag/src/PunchingBag.java
@@ -2,6 +2,8 @@ import gnu.io.CommPortIdentifier;
import javax.swing.event.EventListenerList;
+
+
import java.awt.Rectangle;
import java.awt.geom.Area;
@@ -92,6 +94,10 @@ public class PunchingBag implements Runnable {
void circleExpand(int x, int y, int intensity) {
runningEffects.add(new CircleExpand(x, y, 100));
}
+
+ void squareExpand(int x, int y, int intensity, Colour colour) {
+ runningEffects.add(new SquareExpand(x, y, intensity, colour));
+ }
void noise(Rectangle rect, long time) {
runningEffects.add(new Noise(rect, System.currentTimeMillis() + time));
@@ -184,6 +190,35 @@ public class PunchingBag implements Runnable {
}
}
+
+ class SquareExpand extends Effect {
+ final int x;
+ final int y;
+ final Colour colour;
+ int intensity;
+ boolean drawnSomething = true;
+
+ int heightWidth = 2;
+
+
+ public SquareExpand(int x, int y, int intensity, Colour colour) {
+ this.x = x;
+ this.y = y;
+ this.intensity = intensity;
+ this.colour = colour;
+
+ }
+
+
+ public void draw() {
+ heightWidth += 0.1 + 0.1 + (heightWidth / 20);
+ if (!drawRectCenter(x, y, heightWidth, heightWidth, colour))
+ stop = true;
+
+
+ }
+
+ }
class Noise extends Effect {
final Rectangle area;
diff --git a/PunchingBag/src/PunchingBagGUI.java b/PunchingBag/src/PunchingBagGUI.java
index 9a23741..3aae146 100644
--- a/PunchingBag/src/PunchingBagGUI.java
+++ b/PunchingBag/src/PunchingBagGUI.java
@@ -535,9 +535,9 @@ public class PunchingBagGUI implements MouseListener, MouseMotionListener,
@Override
public void buttonPressed(int x, int y) {
System.out.println("Button Pressed: " + x + " " + y);
- // bag.circleExpand(x, y, 16);
- bag.noise(new Rectangle(0, 0, 9, 20), 5000);
-
+ //bag.circleExpand(x, y, 16);
+ //bag.noise(new Rectangle(0, 0, 9, 20), 5000);
+ bag.squareExpand(x,y, 16, PunchingBag.Colour.Red);
}
@Override