Monday, December 15, 2014

The Final day!

The final project--I wish I was able to more carefully treat the box so you could see the painting I did, I also wish I could have treated the controller I would have wanted to do more with that.

People enjoying our game.

Yay! Look how much fun they are having!

They are having so much fun!

Painting and Polishing




First we tried to find, like, Tupperware or some type of box that was the right size for our arduino and circuit board, but no such luck. So we decided on the measure for the box and went Pro Build in Madison to get the wood for out custom box. We used Masonite because of it was both sturdy and easy to change and paint. We also bought wood glue, and got a little Tupperware to be the extension of our reset button. I applies gesso to all the wood to make it easier to paint. we got very cheap wood cutting supplies from Shopko but it was still very difficult to make clean cuts. When I got the box just as the wood, it was very rough. 


To clean up the edges I used tape around all of the edges and then put gesso over everything very thickly so the that it would be hard to tell where the tape was and have smoother edges.
At first I was planning to paint it all black with red and blue lines to emulate the lines on the design, but instead I really like a dark blue and black texture. 
I tried a couple more complex designs on the button--at first I was going to draw the two head-- and then just one head and it really just ended up looking better and just oh-so-press-able if I left it more simple and just wanted it to feel like a button. I wanted to to look a bit like the top piece of the rock-em-sock-em robot head--and incorporated the little circles like on the robots.

I was really happy with the box after I was done with it, I wish I could have put it all together so that I could treat the top and back edges with the tape too to have it smooth and nice-looking.


Programming


Early Programming test:


Final code:
PImage Rbody, Rhead, Rstick, Rarm, Rpunch, Barm, Bbody,Bhead,Bstick,Bpunch, background;
import processing.serial.*;
import cc.arduino.*;


Arduino arduino;
int ledPin1 = 11;
int ledPin2 = 10;
int ledPin3 = 9;
int ledPin4 = 6;
int ledPin5 = 5;
int ledPin6 = 3;
int fillVal1 = 255;
float health1 = 500;
float health2 = 500;
int butPin1 = 8;
int butPin2 = 7;
int butPin3 = 4;
int prevBut1 = 0;
int prevBut2 = 0;
int prevBut3 = 0;


void setup()
{
size(1000,600);

arduino = new Arduino(this, Arduino.list()[0], 57600);
arduino.pinMode(ledPin1, Arduino.OUTPUT);
arduino.pinMode(ledPin2, Arduino.OUTPUT);
arduino.pinMode(ledPin3, Arduino.OUTPUT);
arduino.pinMode(ledPin4, Arduino.OUTPUT);
arduino.pinMode(ledPin5, Arduino.OUTPUT);
arduino.pinMode(ledPin6, Arduino.OUTPUT);
arduino.pinMode(butPin1, Arduino.INPUT);
arduino.pinMode(butPin2, Arduino.INPUT);
arduino.pinMode(butPin3, Arduino.INPUT);


background = loadImage("Background.png");
image(background,-95,-62);
Rpunch = loadImage("Rpunch.png");
Bhead = loadImage("Bhead.png");
Rhead = loadImage("Rhead.png");
Bpunch = loadImage("Bpunch.png");
Rarm = loadImage("Rarm.png");
Barm = loadImage("BArm.png");

}

void draw ()
{
println(health1);
println(health2);
//println(pmouseX,pmouseY);
//println("First Pin is" + arduino.digitalRead(butPin1));
// println("Second Pin is" +arduino.digitalRead(butPin2));
println("Second Pin is" +arduino.digitalRead(butPin3));


checkHit();


/*
image(Rpunch,235,180);
image(Bpunch,350,180);
image(Rarm,235,225);
image(Barm,430,225);
*/
if(health1 <= 500 && health1 >= 320){
arduino.analogWrite(ledPin1, fillVal1);
arduino.analogWrite(ledPin2, 0);
arduino.analogWrite(ledPin3, 0);
image(Rhead,260,75);

}
else if(health1 <= 319 && health1 >= 160){
arduino.analogWrite(ledPin1, 0);
arduino.analogWrite(ledPin2, fillVal1);
arduino.analogWrite(ledPin3, 0);
image(Rhead,260,75);
}
else if(health1 <= 159 && health1 >= 1){
arduino.analogWrite(ledPin1, 0);
arduino.analogWrite(ledPin2, 0);
arduino.analogWrite(ledPin3, fillVal1);
image(Rhead,260,75);
}
else if(0 >= health1 ){
thread("blink2");
image(Rhead,260,20);
}

if(health2 <= 500 && health2 >= 320){
arduino.analogWrite(ledPin4, fillVal1);
arduino.analogWrite(ledPin5, 0);
arduino.analogWrite(ledPin6, 0);
image(Bhead,575,50);
}
else if(health2 <= 319 && health2 >= 160){
arduino.analogWrite(ledPin4, 0);
arduino.analogWrite(ledPin5, fillVal1);
arduino.analogWrite(ledPin6, 0);
image(Bhead,575,50);
}
else if(health2 <= 159 && health2 >= 1){
arduino.analogWrite(ledPin4, 0);
arduino.analogWrite(ledPin5, 0);
arduino.analogWrite(ledPin6, fillVal1);
image(Bhead,575,50);
}
else if(0 >= health2){
thread("blink1");
image(Bhead,575,10);
}

}
void blink1(){

arduino.analogWrite(ledPin4, fillVal1);
arduino.analogWrite(ledPin5, fillVal1);
arduino.analogWrite(ledPin6, fillVal1);
delay(500);
arduino.analogWrite(ledPin4, 0);

arduino.analogWrite(ledPin6, 0);

arduino.analogWrite(ledPin5, 0);
delay(500);


}
void blink2(){

arduino.analogWrite(ledPin1, fillVal1);
arduino.analogWrite(ledPin2, fillVal1);
arduino.analogWrite(ledPin3, fillVal1);
delay(500);
arduino.analogWrite(ledPin1, 0);

arduino.analogWrite(ledPin2, 0);

arduino.analogWrite(ledPin3, 0);
delay(500);


}

void checkHit(){

// println("button state is " + prevBut1);
image(background,-95,-62);
image(Barm,430,225);
image(Rarm,235,225);

if (arduino.digitalRead(8) == 1){
image(background,-95,-62);
image(Rarm,235,225);
image(Bpunch,350,180);
if (arduino.digitalRead(8)!= prevBut1){

health1-=5;
}

}
prevBut1 = arduino.digitalRead(8);


if (arduino.digitalRead(7) == 1){
image(background,-95,-62);
image(Barm,430,225);
image(Rpunch,235,180);
if( arduino.digitalRead(7)!= prevBut2){

health2-=5;

}
prevBut2 = arduino.digitalRead(7);
}

if (arduino.digitalRead(4) == 1){

if( arduino.digitalRead(4)!= prevBut3){

health1 = 500;
health2 = 500;

}
prevBut2 = arduino.digitalRead(4);
}



}

Rigging up the LEDs




Design Phase

I created all the art assets in Illustrator--overall time probably took about 10 hours or so. I used photos on the Internet for reference. I'm really satisfied with how the design came out. I made the two parts of the arm separate in case we needed to move them but at first we were just going to have one image of the arm bent and rotate it, but that made the character look like he was punching himself in the face. So I gave Colin the heads, the arm extended and the arm bent for each as separate parts and everything else was able to just be a background image. I made nice health bars to possible use, but since we the arduino output displaying health, on-screen health display would have rendered the LED set-up as pointless. I also hoped that when it was reset we could have it say "Fight!" or ready, set fight, but we didn't end up using them in the final thing. 

Idea Phase




When I met with Colin on that day that we all got together to show our toys and what they do I told Colin that his toys kinda looked like controllers and with four buttons on each controller you could have some kind of fighting game with left, right, punch, duck. Like rock em sock em robots! After the mad scramble for groups I ended up with Colin and Kaitlin and the plan was to make rock em sock em robots where I did the art, Colin would be in charge of programming and Kaitlin would do the hardware and help out wherever needed. Yay! We had our plan.