Skip to content

Commit

Permalink
latest
Browse files Browse the repository at this point in the history
  • Loading branch information
boxysean committed Nov 2, 2011
1 parent 5281252 commit eeddd9b
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 9 deletions.
7 changes: 5 additions & 2 deletions Bullet.pde
@@ -1,6 +1,5 @@
int BULLET_WIDTH = 41;
int BULLET_HEIGHT = 10;
int BULLET_SPEED = 3;

int BULLET_NEXT_ID = 0;

Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 6 additions & 4 deletions PewPewDestroy.pde
Expand Up @@ -35,15 +35,15 @@ PImage barHP;
PImage title;
PImage subtitle;

PImage[] winnerImage;

boolean gameOn = false;

void setup() {
size(800,600);
kinect = new Kinect(this);
tracker = new KinectTracker();

link.output(4, "start");

game.setup();

fs = new FullScreen(this);
Expand All @@ -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() {
Expand All @@ -76,15 +78,15 @@ 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);

game.players[0].moveTo(v1.y);

// 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);

Expand Down
3 changes: 2 additions & 1 deletion Player.pde
Expand Up @@ -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;
Expand Down Expand Up @@ -151,6 +151,7 @@ class Player {

if (hp <= 0) {
game.gameOver();
game.winnerId = 1-id;
}
}
}
Expand Down
Binary file added data/chochowins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added data/popowins.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
50 changes: 48 additions & 2 deletions game.pde
Expand Up @@ -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;
Expand Down Expand Up @@ -113,7 +159,7 @@ class Game {
}

void gameOver() {
gameOn = false;
setup();
winCount = frameCount;
link.output(5, "victory");
}
}

0 comments on commit eeddd9b

Please sign in to comment.