Inspiration

The theme itself was the sole inspiration behind our project. We are very keen on building hardware projects, and this is the first time we built a game and that too a classic retro game like Pac-Man for the hackathon. Our hack is surely going to make people feel a little nostalgic and take them back to their childhood days while playing with our hack.

What it does

Just like the classic Pac-Man game, in our hack too, the player will be in control of the movements of the Pac-Man and are supposed to dodge the ghosts that will be coming towards them. The Pac-Man will jump once with a single click of the pushbutton, and the player has to do the same every time to dodge the incoming ghost characters. The game continues as long as the player is able to dodge the ghosts, but as soon as the player fails to do so and crashes into the ghost, i.e. gets eaten by the ghosts, they have to restart the game.

How we built it

The game was built using very basic hardware components that had been lying around in our house. The components used to build Pac-Man 2.0 are breadboard, LCD, Arduino, pushbutton, potentiometer, resistor, and a speaker. With few lines of codes, we have to handle the movement of the Pac-Man, the movement of ghosts and playing the music in the background at the same time. The code is written in the ArduinoIDE and tested the program as a simulation in Tinkercad. After knowing the code is giving a positive result, we started burning the code in the microcontroller and tested it with the LCD and pushbutton. The pushbutton is connected to the interrupt pin of the Arduino so that as soon as the pushbutton gets pressed, the interrupt handler toggles the position of the Pac-Man, referring to a jump. We had to use an interrupt base routine since the microcontroller has to work on the display most of the time. For the sound part, we have reused an old speaker. We sliced the Pac-Man theme song and resampled it at a rate of 4400Hz, and exported it as a wave file with an unsigned 8bit PCM format. After that, we dumped the sliced samples in a text file as a byte array, stored the array in the flash memory of the microcontroller; the used timer interrupts to play the tone on pin 11. And that's how we implemented the sound of the Pac-Man.

Challenges we ran into

Fitting the music samples in the microcontroller's flash memory was a bit tough. Since the music file was around, 33Kb and your microcontroller have only 29266 bytes or 29Kb. Accessing the timer interrupts directly was sacrificing the performance of other parts of the program. Finding the correct gameplay so that it can fit inside the 16x2 LCD that too without losing fun was the toughest part. Building the code, handle the data efficiently, since you have a very small amount of memory, update the screen at perfect timing for smooth graphics was also a hard battle too.

Accomplishments that we're proud of

Being able to incorporate the classic Pac-Man game melody into our hardware hack was one of the biggest accomplishments. And finally, finishing the hack on time, and playing the game without any glitch, in addition to the background retro arcade Pac-man music, was the ultimate accomplishment we feel. And another mention worthy accomplishment is that 50% of our team comprised of first-time hackers, and still, we were able to complete the project.

What we learned

We learned about music sampling, and how a music file is stored digitally and how to recreate that sound from the digital data. There were timer interrupts we got to know about, also how they affect the program upon calling frequently on a tight running program. A bit of game theory, where you get to know about how to approach a problem by games. We learned how to overcome certain difficulties while constructing the algorithm, as well as time-management is the key to creating a successful project.

What's next for Pac-Man 2.0

Even though Pac-Man is a classic retro arcade game, we would try to bring some more twists and turns to it by adding in some easter eggs in Pac-Man 2.0. We would also try to fabricate a PCB design to turn it into a playable console by building a 3D printed casing.

Built With

Share this project:

Updates