Browse files

Added new drop routine. Fixed fade in.

  • Loading branch information...
1 parent 400720d commit 9e6b2abcff92a827a8c11edc3cd7471cdd168060 @potatono potatono committed Jul 2, 2012
Showing with 77 additions and 4 deletions.
  1. +69 −0 DropTheBomb.pde
  2. +8 −4 domeTransmitter.pde
View
69 DropTheBomb.pde
@@ -0,0 +1,69 @@
+class DropTheBomb extends Routine {
+ float bombX;
+ float bombY;
+ float bombSpeed;
+ float flashSpeed;
+ float flashBrightness;
+ float blastRadius;
+ float blastSpeed;
+
+ void setup(PApplet parent) {
+ super.setup(parent);
+ bombSpeed = height / (frameRate*3);
+ flashSpeed = 255 / (frameRate*1);
+ blastSpeed = max(width,height) / (frameRate*5);
+ }
+
+ void reset() {
+ bombX = random(width);
+ bombY = 0;
+ flashBrightness = 255;
+ blastRadius = 0;
+ }
+
+ void draw() {
+ if (bombY < height) {
+ drawBomb();
+ bombY += bombSpeed;
+ }
+ else if (flashBrightness > 0) {
+ drawFlash();
+ flashBrightness -= flashSpeed;
+ }
+ else if (blastRadius/2 < width || blastRadius/2 < height) {
+ drawBlast();
+ blastRadius += blastSpeed;
+ }
+ else {
+ newMode();
+ }
+ }
+
+ void drawBomb() {
+ int c = 255;
+ background(0);
+
+ for (int i=0; i<5; i++) {
+ stroke(c);
+ point(bombX,bombY-i);
+ c = c - 32;
+ }
+ }
+
+ void drawFlash() {
+ colorMode(HSB);
+ background(0, 255 - flashBrightness, flashBrightness);
+ colorMode(RGB);
+ }
+
+ void drawBlast() {
+ noStroke();
+ rectMode(CENTER);
+ background(0);
+ for (int i=0; i<5; i++) {
+ fill(255-(i*16),64-(i*4),32-(i*2));
+ ellipseMode(CENTER);
+ rect(0,height,width*2,blastRadius/(i+1));
+ }
+ }
+}
View
12 domeTransmitter.pde
@@ -15,7 +15,7 @@ boolean VERTICAL = false;
int FRAMERATE = 40;
String hostname = "127.0.0.1"; //"192.168.1.130";
int TYPICAL_MODE_TIME = 300;
-Routine drop = new Seizure();
+Routine drop = new DropTheBomb();
Routine pong = new Pong();
Routine[] enabledRoutines = new Routine[] {
@@ -68,6 +68,8 @@ void setup() {
for (Routine r : enabledRoutines) {
r.setup(this);
}
+
+ drop.setup(this);
}
void setFadeLayer(int g) {
@@ -110,8 +112,10 @@ void draw() {
pong.setup(this);
}
- if (controller.buttonA || (keyPressed && key == 'a')) {
- drop.draw();
+ if (controller.buttonA || (keyPressed && key == 'a') && currentRoutine != drop) {
+ //drop.draw();
+ currentRoutine = drop;
+ drop.reset();
}
else if (controller.buttonB || (keyPressed && key == 'c')) {
newMode();
@@ -135,7 +139,7 @@ void draw() {
}
if (fadeInFrames > 0) {
- setFadeLayer(240 - fadeInFrames*8);
+ setFadeLayer(240 - fadeInFrames * (240 / FRAMERATE));
blend(fadeLayer, 0, 0, WIDTH, HEIGHT, 0, 0, WIDTH, HEIGHT, MULTIPLY);
fadeInFrames--;
}

0 comments on commit 9e6b2ab

Please sign in to comment.