I have been playing the Stacker arcade game since I was 8 years old, in a local arcade back in Brazil. The goal of the game is to stack a pile of block(s) until the top of the screen. If the player fails to stack the blocks on top of the "stack" the player will then go to the upper floor with the remaining amount of blocks that were correctly stacked. The block's movement speed increases after established levels, those being at level 7 and at level 11, the number of blocks will decrease when reaching these levels to increase the difficulty.
Video |
The Microcontroller used for this project is the BG22-EK4108A from Silicon Labs, the Diymore 2.42" OLED Display Module with 128x64 resolution configured for SPI mode with SSD1309 driver, and a KSC721G LFS button all mounted on a copper clad that connects all the hardware. An USB cord will be required to connect the microcontroller to a power source and code loading and debuging.
Top view | Side view | Schematic | ||
The project was coded in the C language using the Simplicity Studio IDE from Silicon Labs. At the beginning I was coding with only one moving block, just to learn and get used to the logic, then I implemented movements of two blocks, and then with three ones.
The block movement logic works the following way: There is an infinite loop that starts drawing 3 blocks at the 1st floor, then it increments the index of every block by one if the blocks are moving to the right direction, and if the direction is to the left, the indexes will be decremented by one, every time that the blocks change indexes, there is one block that is deleted, this block will be the right most block when moving to the left, and it will be the left most block when moving to the right. Every time a block hits the wall, the method will call itself in the opposite direction. To make it look like the blocks are moving smoothly, there is a timer after every loop iteration, this timer gets faster and faster as the player progresses to the higher floors.
When the button is pressed, the method will call itself going to the right direction, but incrementing the floor by one, so that the player can stack the blocks. There will be two arrays of integers, that keeps track of the indexes of the blocks on the previous floor, and one that keeps track of the indexes on the current floor when the button is pressed, the player will go up one floor with the amount of blocks that were matched to the previous blocks, if the player did not match any block, the player will lose the game and a "Lost" message will pop up, if the player gets to the highest level and the blocks are matching, the player will win the game and a "Won" message will pop up.
This project helped me develop my coding skills, especially in C. I did have some previous experience with microcontrollers and C in our Operating System class. Building this project was a lot of fun, sometimes I got stuck, especially when comparing the current block location to the previous one, but it really helped me improve my coding skills. My code could definitely be better, but I believe I have tried my best at the moment, but I would start differently if I had to do this project again.