Punch the Alien!

For our final project, Sara and I built an alien head that responds to punches. When you hit the alien, injuries appear in a Processing sketch that correspond to the place where you hit it. It is constructed from a foam wig head and FSRs. We sanded the face off and added sensors to the areas that correspond to the forehead, eyes, nose, and mouth. The sensors were then connected to the Arduino.

I created some injuries for the alien in Photoshop, which we then used in the Processing sketch. When the appropriate sensor was hit, the opacity of the injuries would increase, making the bruises appear.

This video shows the first working version of the alien head, complete with sensor layout.

Once we had our head operational, we added some more injuries, sounds, and effects. We also added an alien mask to make it more realistic (if you can call a latex alien mask realistic). This is the final version:

Here’s the Arduino code:

[code lang="c"]void setup()
{
  // start serial port at 9600 bps:
  Serial.begin(9600);
  
}

void loop() {
  for (int thisSensor = 0; thisSensor < 5; thisSensor++) {
    int sensorValue = analogRead(thisSensor);
    Serial.print(sensorValue, DEC);
   // Serial.print(",");

    if (thisSensor ==4) {
      Serial.println();
    }
    else{
      Serial.print(","); 
[/code]

Here is the Processing code:

[code lang="java"]import processing.serial.*;
Serial myPort;

import ddf.minim.*;
Minim minim;

AudioPlayer punch1;
AudioPlayer punch2;
AudioPlayer FH;
AudioPlayer cheer;
AudioPlayer mommy;

PFont font;

PImage alien;
PImage forehead;
PImage lefteye;
PImage righteye;
PImage nose1;
PImage nose2;
PImage cloudleft;
PImage cloudright;
PImage frown;
PImage brains;
PImage mouth;
PImage ouch;
PImage powyes;
PImage finishHim;
PImage ufo;

int f=0;
int r=0;
int l=0;
int n=0;
int m=0;

int Fopacity = 0;
int Lopacity = 0;
int Ropacity = 0;
int Nopacity = 0;
int Mopacity = 0;

void setup()
{
  String portName = Serial.list()[0];
  myPort = new Serial(this, portName, 9600);

minim = new Minim(this);

punch1 = minim.loadFile("punch1.wav");
punch2 = minim.loadFile("punch2.wav");
//mommy = minim.loadFile("mommy.wav");
FH = minim.loadFile("finish_him.wav");
cheer = minim.loadFile("cheer2.wav");

  size(599, 720);
  alien = loadImage("alien.jpg");
  ufo = loadImage("ufo.png");
  forehead = loadImage("alienhead.png");
  lefteye = loadImage("lefteye.png");
  righteye = loadImage("righteye.png");
  nose1 = loadImage("nose1.png");
  nose2 = loadImage("nose2.png");
  cloudleft = loadImage("cloudleft.png");
  cloudright = loadImage("cloudright.png");
  frown = loadImage("frown.png");
  brains = loadImage("brains.png");
  mouth = loadImage("mouth.png");
  ouch = loadImage("ouch.png");
  powyes = loadImage("POWyes.png");
  finishHim = loadImage("finish_him.png");
  finishHim.resize(2*width/3, 0);
  
  font= loadFont("RosewoodStd-Regular-48.vlw");
  textFont(font);
}

void serialEvent (Serial myPort) {

  String myString = myPort.readStringUntil ('n');
  if (myString != null) {
    myString = trim(myString);
    int sensors[] = int(split(myString, ','));

    if(sensors.length >= 5) {
      m = sensors[0];
      f = sensors[1];
      r = sensors[2];
      n = sensors[3];
      l = sensors[4];
     
    }
    
    
    if (f>100)
    {
      Fopacity += 15;
      punch1.play();
     
    }

    if (l>100)
    {
      Lopacity += 15;
      punch1.play();
      
    }

    if (r>100)
    {
      Ropacity += 15;
      punch2.play();
     
    }

    if (n>100)
    {
      Nopacity += 25;
      punch2.play();
     
    }
    
    if (m>100)
    {
      Mopacity += 15;
      punch1.play();
     
    }
  }
}
void draw () {
  background(alien);

  //frown
  if (Fopacity > 0 || Lopacity > 0 || Ropacity > 0 || Nopacity > 0)
  {
    tint(255, 255);
    image(frown, 0, 0);
  }

  //forehead bruise & brains
  tint(255, Fopacity);
  image(forehead, 0, 0);
  
  if(Fopacity == 210)
  {
    image(powyes, width/2-144, height/2);
  }
  
  if(Fopacity >= 255)
  {
    tint(255, 255);
    image(brains, 0, 0);
  }

  //left eye bruise
  tint(255, Lopacity);
  image(lefteye, 0, 0);
  
  if(Lopacity == 210)
  {
    image(powyes, width/2-144, height/2);
    //mommy.play();
  }
  
  if(Lopacity >= 255)
  {
    tint(255, 255);
    image(cloudleft, 0, 0);
  }
  
  //right eye bruise
  tint(255, Ropacity);
  image(righteye, 0, 0);
  
  if(Ropacity == 210)
  {
    image(powyes, width/2-144, height/2);
    //mommy.play();
  }
  
  if(Ropacity >= 255)
  {
    tint(255, 255);
    image(cloudright, 0, 0);
  }

  //nosebleed
  tint(255, Nopacity);
  image(nose1, 0, 0);
  
  if(Nopacity == 210)
  {
    image(ouch, width/2-164, height/2);
  }

  if (Nopacity >= 255)
  {
    tint(255, 255);
    image(nose2, 0, 0);
  }
  
  //mouth bleed
  tint(255, Mopacity);
  image(mouth, 0, 0);
  
  if(Mopacity == 210)
  {
    image(ouch, width/2-164, height/2);
  }
  
  //finish him
  if(Fopacity >= 225 && Lopacity >= 225 && Ropacity >= 225 && Nopacity >= 225)
  {

    image(finishHim, width/2-200, height/3);
    FH.play();
  }
  
  //end
  if(Fopacity >= 255 && Lopacity >= 255 && Ropacity >= 255 && Nopacity >= 255)
  {
    background(0);
    stroke(255);
    strokeWeight(1.5);
    randomSeed(20);
    for(int i=0; i<600; i++)
    {
      point(random(width), random(height));
    }
    noStroke();
    
    image(ufo,  width/2-150, height/2);

    text("YOU WIN!", width/2, height/3);
    cheer.play();
  }
}

void close () {
 punch1.close(); 
 punch2.close();
 //mommy.close();
 FH.close();
 cheer.close();
 minim.stop();
 super.stop();
[/code]