During my second semester of engineering at uWaterloo I entered the Math and Engineering department hackathon called ‘EngHack’. I worked with three other mechatronics engineering students (Tom Meredith, Will Clark, and Tomas Bakos Lang) to create this immersive cross platform gaming system. The user holds a physical controller with both hands and uses a joystick to move, buttons to fire and tilts the controller to rotate the turret of the tank. A breadboard located at the bottom of the screen features an array of LEDs and a buzzer to give the player an indication of their current health level. The objective is to move around the map and destroy the enemies while dodging their bullets, water, explosives, and obstacles on the screen. Due to the 20 hour limitation of the hackathon, the game itself was kept quite simple. So how does it work?
The controller consists of an Arduino connected to a joystick, several buttons and two tilt sensors at the top corners of the breadboard. The Arduino was programmed in the Arduino IDE and continuously takes readings and listens for a byte over a serial connection from a Raspberry Pi. Once it receives a byte, the Arduino gathers all of the data from each sensor into one line and sends it as one transmission over serial to the Raspberry Pi (to keep all data synchronized from the same frame) which then breaks the data up and processes it. The Raspberry Pi was programmed with Python and utilized the pygame game engine for most of the onscreen object processing and movement. The player's tank, each enemy, and the tiles on the map (including water, explosives, destructible crates and brick walls) were all implemented as sprite objects with various characteristics. Dictionaries were generated of all collisions each frame and the game reacted accordingly (ie. decreasing player health, destroying enemies etc.). The panel of LEDs was run directly off the Pi and was updated during each frame refresh and the buzzer code utilized the time clock function to avoid disrupting the frame rate of the game. Our team used GitHub to allow us to work on the project in parallel and sync our code to the Raspberry Pi.
Our team placed second in the Hackathon out of about 30 - 40 teams. We were quite pleased with the results and had a lot of fun learning Python, pygame, serial communication, more hardware interfacing and how to used GitHub. We worked well as a team and are looking forward to another hackathon together.