Punch Me, I Dare You – Kinect Game

[PHOTOS and VIDEO COMING SOON]

Overview
Punch Me, I Dare You is a game that Tony Lim and I worked on for our ICM final. It uses a hacked Kinect, Processing, and MaxMSP. Download the full game here.

The Game
It’s a stress-relieving game that encourages the  player to punch areas of a face on screen (See my teasing face above). There are five areas: left eye, right eye, nose, left cheek, and right cheek. Each area must accumulate a certain amount of damage through punching before the player can move to the next area. A short clip of high-energy music plays each time a punch is landed, and the music progresses as the player progresses through the game. The game is timed, encouraging the player to want to beat their own time. Continue reading

Kinect Game Progress

I was finally able to get started with the Kinect and Processing thanks to the OpenSimpleNI library. SimpleOpenNI is a wrapper for OpenNI and NITE for Processing. Thanks to Sheiva for recommending it to me. Once I  had everything working, I found this Hands Tracking example and modified it to track both hands. With that, I merged my game code (which had the all the game functions using a mouseover for prototyping) and my Kinect tracking code to create this demo.

The game consists of  punching different areas of a face in a predetermined sequence. As more damage is inflicted on the area, the picture will change. Then, once that area has reached a certain amount of damage, you will be prompted to hit another area. Here, I’m am simulating the areas of the face with circles, and they get darker to simulate the damage. I’m only  demoing 2 areas in this version. Also there is a bug that I’m looking into where the first area reaches it’s maximum damage really quickly.

Download the code.

Mouse Position is not Updated in while-loop

So I’d been racking my brain on this for some time, wondering why my sketch wasn’t working. Then I realized what was wrong. Hopefully anyone in the same predicament and searching the web will find this helpful.

Mouse Position cannot updated inside of a while-loop.

Run this and see:
void setup(){
size(300,300);

}

void draw(){

while (mouseX < 150){
println(“in while-loop”);
println(“frameCount: ” +frameCount);
println(“mouse position: “+mouseX+”, ” +mouseY);
}
println(“out of loop”); //you will never see this

}

ICM Final: Getting Started with Kinect…

…has been a PAIN in the ass. Here’s where I’m at:

So it’s off to the genius bar.

Final Project: Kinect Game

After presenting our ideas for the ICM final last week, Tony and I decided to work together on a project. He wanted to build a video game for the Kinect for stress relief. It’s a game where the player gets to throw punches at a character and beat them. I’ve been curious about working with the Kinect and I was also interested in building a game. So this seemed like a prime opportunity.

Tony has worked with the Kinect before–he’s midterm used the Kinect for a playing a music interface–so he’s been sharing information on how to get setup. I will share progress over the next couple of weeks.

 

Final Proposal – Idea 2: Watch out! Tomatoes!

My second idea for my ICM final is a game using the webcam as an interface. The user has to dodge incoming tomatoes that will be thrown at them.

I need to flesh this idea out much more.

Final Project Proposal – Idea 1: Cards Interface

Having completed our presentation of the ME&Useum at Applications, we had collected a number of personal stories from our classmates. Since I came to ITP interested in interface design and user experience, I thought it might be interesting to design and code an interface for these stories. Continue reading

Pandora CoverFlow with Processing

For my ICM midterm, I wanted to do something with a music library. My original idea was to use the iTunes music library xml file, but it turns out that that file is not a true xml file, it’s formatted as a plist (or property list). For the first few days of working on this, I wrote code to try to transform the plist to an xml I could work with in Processing.
It was getting messy.
Then my computer crashed and because I didn’t save (lesson learned!) I lost a whole day of work.

So instead, I used an xml file from Pandora which shows a users latest activity. Users input their username, and the application will show you their latest activity pulled from an xml file.

I added some mouse-enable effects for scrolling and on rollover.

Download the files here.

Spanglish Shakespeare

My script is loading a Shakespeare Sonnet and changing some of the words to their Spanish equivalent. The translation as a whole is not great because translation involves much more than one-to-one switches. It just shows the complexities of language. While there are definite rules in language, the rules are different in each language. For example, in English we can have a phrase that is article adjective noun (the big house), but in spanish it is article noun adjective (la casa grande).


String lines[];

void setup() {
  size(500, 500);
  background(0);
    lines = loadStrings("http://www.michelleboisson.com/dropbox/sonnet.txt");
  
  //println("there are " + lines.length + " lines"); 
  for (int i=0; i < lines.length; i++) { 
    println(lines[i]);
  }
  println("there are "+lines.length+" lines");

  for (int i=0; i < lines.length; i++) {
    lines[i] = lines[i].replace("love", "amour");
    lines[i] = lines[i].replace("should", "tener que");
    lines[i] = lines[i].replace("sweet", "dulce");
    lines[i] = lines[i].replace("beauty", "belleza");
    lines[i] = lines[i].replace("house", "casa");
    lines[i] = lines[i].replace("none", "nunca");
    lines[i] = lines[i].replace("know", "saber");
    lines[i] = lines[i].replace("father", "padre");

  }
  for (int i=0; i < lines.length; i++) { 
    println(lines[i]);
  }
  int y=0;
  for (int i = 0; i < lines.length; i++){
    //put the next line down 18 characters
    y = y + 28;
    text(lines[i], 10, y);
  } 
  
}

void loop() {
  
 // drawHeadlines(lines);
  
}
}

Juggling Game

This is a simple jugging game I created for this week’s assignment. I wanted to replace the 2 circles with images of circus balls but I having problems. I also couldn’t get them to rotate.

I started with the Example code in Processing for BouncyBubbles and I built the game on top of that.

/* This stetch will produce a little juggling game */

//int numBalls = 2;
int numBalls = 3;
float spring = 0.05;
float gravity = 0.03;
float friction = -0.9;
Ball[] balls = new Ball[numBalls];

int gameLength = 30; //how long the game will last in seconds

int timer; //time in seconds
int counter = 0;
int timedScore;
int savedTimeScore;
int ballsUpStartTime;
//int ballCounter = 0; //number of balls in the air

void setup() { 
  size(400, 700);
  noStroke();
  smooth();

  for (int i = 0; i < numBalls; i++) {
    balls[i] = new Ball(random(width), height, random(20, 40), i, balls);
  }
}

void draw() {

  background(0);
  for (int i = 0; i < numBalls; i++) {
    balls[i].collide();
    balls[i].move();
    balls[i].display();
  }
  //set the countdown timer
  timer = gameLength - int(millis()/1000);
  text ("Time left: " + timer, 20, 10);

  //set the ball counter = number of balls in the air
  int ballCounter=0;
  for (int i=0; i<numBalls; i++) {
    if (balls[i].onTheFloor() == false) {
      ballCounter++;
    }
  }

  if (ballCounter == balls.length) {
    //reset the time counter
    println("All BALLS UP!");
    
    //start timing
    //timedScore += int(frameCount /60);
    ballsUpStartTime = int(millis()/1000);
    println("millis/1000 "+int(millis()/1000));
    timedScore = int(millis() /1000) - ballsUpStartTime;
    println("timedScore : "+timedScore);
  }else { // if there's a ball on the ground, save the time
    //check if the time is bigger that the other time
    if (timedScore > savedTimeScore){
      savedTimeScore = timedScore;
    }
    
    timedScore = 0;
  }

  text ("Balls in the Air: " + ballCounter, 10, 50);

  if (timer == 0) {
    noLoop();
    background(0);
    fill(150);
    text("Your top score: "+ savedTimeScore, width/2, height/2);
  }
}// end draw



void mousePressed() {
  for (int i = 0; i < numBalls; i++) {
    balls[i].collideWMouse(mouseX, mouseY);
  }
}
class Ball {
  float x, y;
  float diameter = 50;
  float vx = 0;
  float vy = 0;
  int id;
  int ballRotation = 0;
  int push = 2;//for the on-click function
  Ball[] others;
  PImage b;

  boolean onTheFloor = true;

  Ball(float xin, float yin, float din, int idin, Ball[] oin) {
    x = xin;
    y = yin;
    id = idin;
    others = oin;
    b = loadImage("circusball.gif");
  } 

  void collide() {
    for (int i = id + 1; i < numBalls; i++) {
      float dx = others[i].x - x;
      float dy = others[i].y - y;
      float distance = sqrt(dx*dx + dy*dy);
      float minDist = others[i].diameter/2 + diameter/2;
      if (distance < minDist) { 
        float angle = atan2(dy, dx);
        float targetX = x + cos(angle) * minDist;
        float targetY = y + sin(angle) * minDist;
        float ax = (targetX - others[i].x) * spring;
        float ay = (targetY - others[i].y) * spring;
        vx -= ax;
        vy -= ay;
        others[i].vx += ax;
        others[i].vy += ay;
      }
    }
  }

  void collideWMouse(int mousePosX, int mousePosY) {

    if (mousePosX >x - diameter/2 && mousePosX < x + diameter/2 && mousePosY > y-diameter/2 && mousePosY < y + diameter/2) {
//      println("You hit Ball #" + id); 
//      println("on the Floor: " +onTheFloor());
//      println("Y: " +y);

      vy = -(Math.abs((vy+1) + push));
    }
  }

  void move() {
    vy += gravity;
    x += vx;
    y += vy;
//    this.rotate(ballRotation++);
    if (x + diameter/2 > width) {
      x = width - diameter/2;
      vx *= friction;
    }
    else if (x - diameter/2 < 0) {
      x = diameter/2;
      vx *= friction;
    }
    if (y + diameter/2 > height) {
      y = height - diameter/2;
      vy *= 0; 
      fill(255, 0, 0);
    } 
    else if (y - diameter/2 < 0) {
      y = diameter/2;
      vy *= friction;
    }
  }

  void display() {
    fill(255, 204);
    ellipse(x, y, diameter, diameter);
//    image(b, x, y, diameter, diameter);
  }

  boolean onTheFloor() {
    if (y + diameter/2 >= height) {
      onTheFloor = true;
    }
    else {
      onTheFloor = false;
    }
    return onTheFloor;
  }
}//end Ball class

Proudly powered by WordPress
Theme: Esquire by Matthew Buchanan.