Luo Yi Tan – Final Project
For my final project, I made a game rewarder.
I wanted to make some sort of game, where a machine dispenses some kind of reward whenever you beat it. Pavlovian, some would say.
In the game, you move a small square with your mouse, and click to shoot. If you shoot a big M&M, a smaller M&M will fall from it. The goal of the game is to collect as many little M&Ms as possible.
Here is a screenshot of the game:
The game itself is made in Processing. It wasn’t too hard to implement, but getting the game logic down needed some work, as I have never coded a game from scratch before. The highscore is read and saved in a txt file in the Processing folder.
You can see it in action here:
In the beginning, I designed a box to laser cut, but I accidentally messed up the measurements of the box. So, I improvised, using a cardboard box I had lying around and a garden hose. It turned out well, surprisingly enough. The gear that dispenses the candy was laser cut, moved by two other gears that are connected to a servo. This is controlled by an Arduino, which reads a value from Processing that tells it whether a player has beat the high score or not.
The mechanism is pretty simple:
This is the fritzing diagram:
Extra ideas I had but didn’t have time to do: Dispensing something undesirable when you don’t beat the high score, and allowing the user to take a picture of their face and put it on the player character.
The Processing code is rather long and also split up into several files, so I have uploaded it on mediafire as a zip file.
http://www.mediafire.com/?o6mwvd2il11aa24
The Arduino code is pretty straightfoward, it simply checks if a signal that the player has beat the high score is sent from Processing:
#include
Servo servo1;
void setup()
{
servo1.attach(9);
servo1.write(90);
Serial.begin(9600);
}
void loop() {
// check if data has been sent from the computer:
if (Serial.available()) {
// read the most recent byte (which will be from 0 to 255):
byte pos = Serial.read();
// move a servo and RELEASE CANNDEH
if (pos == 1) {
servo1.write(0);
delay(3000);
servo1.write(90);
delay(1000);
//servo1.detach();
}
}
}