My idea came from the popular retro game called Frogger. In that game, the goal is to navigate the character from one side of the street to the other without getting hit by the traffic. At the beginning, my project was based on the same idea. But, since a simple LED board is not capable of displaying fancy graphics and various colors like the original game, what I created in the early stages felt pretty empty and boring. So, instead of having just one level and making it progressively more difficult by increasing the speed of the enemies (traffic), I decided to make the game more entertaining by creating multiple unique levels. In this game, the player controls a green square, and is able to move in four directions. Most levels contain walls and moving enemies. As in the original game, the goal is to avoid getting hit by the enemies and make it safely onto the other side. The game contains 9 levels and a final boss level.
Video |
![]() Video clip |
---|
The Microcontroller used for this project is BGM220-EK4314A from Silicon Labs and the LED board used was the Adafruit bicolor 8x8 led square matrix with I2C interface [ADA902]. Also, a set of four 12mm square tactical colored buttons are placed on the LED board. Lastly, a usb cord connecting the microcontroller to a power source is necessary.
Schematic | Top view | Side view | ||
The project was coded in the C language using the Simplicity Studio IDE from Silicon Labs. Even though I have not coded in C before, I had experience with C++, so adapting to C was quite easy. Overall, the project was not so technically demanding. Once I had an idea for a particular level, implementing it in code was simple most of the time. Drawing the maps for each level and coming up with their behavior was sometimes trickier than the implementation itself. The code structure is fairly simple. There is a main loop handled by RTCC functions that repeatedly runs some of the game's main tasks. Those include drawing the character, the current level behavior, the user input as well as collision detection.
The player (frog) cannot move through the walls, so nothing would happen if you try to go through it, the player would just remain in the same position. If the player hits a moving object(an enemy), the player gets reset to the starting position for that level.
When a hit occurs, the game will restart from the current level. At first, I wanted the player to have 3 lives, and reset to level 1 once all 3 lives are lost. I like that idea a lot more but using 3 squares to show the current number of lives left would mean I have less space to create the levels themselves, so I changed my mind. So, because a player has only 1 life, I thought resetting to level 1 each time the player is hit would make the game too difficult.
When level 10 is complete, the screen just turns off, but I will probably add some kind of a message later. In level 10, the enemy is randomly moving left and right, shooting at the player. The player also shoots at the enemy. But, the player cannot shoot at the enemy whenever they want, since I feel the level would be too easy that way. Instead, the ammo(an orange/yellow square) will appear randomly on the floor(next to the player at a random position), and once the player collects the ammo, then they can shoot once. Then, the ammo will appear randomly again, and so on. There are barriers in the middle of the screen on each side to help the player hide while they are waiting for the ammo to appear. If a player shoots at the barrier, the bullet will be blocked. If the enemy hits the player, the player will just reset to the starting position, which means the player can never lose but I plan on at least resetting the enemy's health bar(the green row at the top) to full every time the player gets hit.
I have not had experience with microcontroller projects prior to this course. Luckily, Sergei did the hard work by assembling the hardware parts and even provided a sample code for the project. The code handled all of the button events(the player's controls) and most of the necessary functions such as setting up RTCC and the LETIMER. Building the project from scratch would have been a challenge, so the sample code was a big help for me. I started playing around with it and tried to fully understand it. Once I got comfortable, translating my ideas into code went really well. Overall, it was more than a fun project and it made me really interested in microcontroller programming.
Last modified:Mon, Jan 23, 2023.