diff --git a/Bullet.pde b/Bullet.pde index fbf2f21..1cc194f 100644 --- a/Bullet.pde +++ b/Bullet.pde @@ -1,6 +1,5 @@ int BULLET_WIDTH = 41; int BULLET_HEIGHT = 10; -int BULLET_SPEED = 3; int BULLET_NEXT_ID = 0; @@ -29,7 +28,11 @@ class Bullet { } void move() { - x += speed; + if (playerId == 0) { + x += game.BULLET_SPEED; + } else { + x -= game.BULLET_SPEED; + } } boolean equals(Object o) { diff --git a/PewPewDestroy.pde b/PewPewDestroy.pde index 61d26ec..deb8b8f 100644 --- a/PewPewDestroy.pde +++ b/PewPewDestroy.pde @@ -35,6 +35,8 @@ PImage barHP; PImage title; PImage subtitle; +PImage[] winnerImage; + boolean gameOn = false; void setup() { @@ -42,8 +44,6 @@ void setup() { kinect = new Kinect(this); tracker = new KinectTracker(); - link.output(4, "start"); - game.setup(); fs = new FullScreen(this); @@ -61,6 +61,8 @@ void setup() { title = loadImage("title.png"); subtitle = loadImage("subtitle.png"); + + winnerImage = new PImage[] { loadImage("popowins.png"), loadImage("chochowins.png") }; } void draw() { @@ -76,7 +78,7 @@ void draw() { // Let's draw the raw location PVector v1 = tracker.getPos1(); - fill(255,128,128,200); + fill(128,128,255,200); noStroke(); ellipse(v1.x,v1.y,20,20); @@ -84,7 +86,7 @@ void draw() { // Let's draw the "lerped" location PVector v2 = tracker.getPos2(); - fill(128,128,255,200); + fill(255,128,128,200); noStroke(); ellipse(v2.x,v2.y,20,20); diff --git a/Player.pde b/Player.pde index 37d6e75..74c8f9e 100644 --- a/Player.pde +++ b/Player.pde @@ -57,7 +57,7 @@ class Player { void shootBullet() { int x = 0; - int speed = BULLET_SPEED; + int speed = game.BULLET_SPEED; if (sideLeft) { x = HP_BAR_WIDTH + BAR_BUFFER + PADDLE_WIDTH; @@ -151,6 +151,7 @@ class Player { if (hp <= 0) { game.gameOver(); + game.winnerId = 1-id; } } } diff --git a/data/chochowins.png b/data/chochowins.png new file mode 100644 index 0000000..5e0f3af Binary files /dev/null and b/data/chochowins.png differ diff --git a/data/popowins.png b/data/popowins.png new file mode 100644 index 0000000..e8dde83 Binary files /dev/null and b/data/popowins.png differ diff --git a/game.pde b/game.pde index bf528aa..af17ccb 100644 --- a/game.pde +++ b/game.pde @@ -9,16 +9,62 @@ int SHOOT_INTERVAL = 2000; // ms class Game { Player players[] = new Player[2]; + int BULLET_SPEED = 5; + int nextShootTime; +// int winCount = 0; +// int winnerId = 1; + + int winCount = -1; + int winnerId; + + int startFrame; + void setup() { players[0] = new Player(0, "A", #FF0000, true); players[1] = new Player(1, "B", #0000FF, false); + + startFrame = frameCount; + link.output(1, "start"); + link.output(6, 1); } void draw() { int ms = millis(); + if (winCount >= 0) { + int frame = frameCount - winCount; +// boolean blinkOn = (frame % 10) / 5 == 0; + boolean blinkOn = true; + if (frame >= 100) { + gameOn = false; + setup(); + } else if (blinkOn) { + image(winnerImage[winnerId], 0, 0); + } + + return; + } + + int frame = frameCount - startFrame; + + if (frame > 900) { + BULLET_SPEED = 14; + SHOOT_INTERVAL = 800; + link.output(6, 4); + } else if (frame > 600) { + BULLET_SPEED = 11; + SHOOT_INTERVAL = 1200; + link.output(6, 3); + } else if (frame > 300) { + BULLET_SPEED = 8; + SHOOT_INTERVAL = 1600; + link.output(6, 2); + } + +//println("speed " + BULLET_SPEED + " interval " + SHOOT_INTERVAL); + if (!gameOn) { if (players[0].y < 50 && players[1].y < 50) { gameOn = true; @@ -113,7 +159,7 @@ class Game { } void gameOver() { - gameOn = false; - setup(); + winCount = frameCount; + link.output(5, "victory"); } }