This project was inspired by an Android puzzle game called Shift that I found in the open-source Apps repository F-Droid many years ago.The game has a board of 6 by 6 cells that are filled with different colors. The game starts with all the edges cells filled with a random color and your goal is move the walls to left or right and the ceil and floor to down or up to let the pieces of same color to meet and then be removed from the game board.
So when I saw the APDS9960 Gesture Sensor demo at Sparkfun few years ago I realized it was the perfect sensor to create an interactive real version of Shift game controlled by gesture and using an RGB LED Matrix to create the 6 x 6 cells.
I used an APA102 RGB 16x16 matrix to create the game board:
The main reason to use APA102 Matrix instead WS2812 (that is lower cost) is because APA102 uses standard SPI protocol to control it. Also because there is a driver on NuttX that let us to use the APA102 Matrix as a "LCD-like" display:
We will use 14 pieces of matte black acrylic "comb" like this:
to create the Game Board grid, separating each cell with 4 LEDs.
As you can see to create a 6 x 6 cell game board we will have 2 horizontal LEDs and 2 vertical LEDs per cell. So it will 12x12 LEDs from this 16x16 Matrix. It means we will not use 2 LEDs in the edges ( 2 + 12 + 2 = 16).
You will need to glue a bond paper on top of this matrix to create a nice visual separation for the cells:
Connect the wires from APDS9960 module to the ESP32-Devkitc and the wires from APA102 to the ESP32-Devkitc as explained in the Fritzing schematic:
Also power to APA102 Matrix with 5V using an external 2A power supply (the jack connector in middle of schematic).
After everything is connected, follow the instructions to compile the brickmatch game as explained in the section Code in the attachment section.
If you are new to NuttX RTOS, then start installing the prerequisites in your computer: https://nuttx.apache.org/docs/latest/quickstart/install.html
Here there is a sequence showing how to move the walls/ceil/floor using the gestures movements:
See that the vertical red blocks are near to the horizontal red blocks. So to unite them we need to move again to the right:
Finally we united 4 red blocks:
See they were removed:
There still room for improvements, for example we need to create a 3D case to put the matrix and gesture sensor; audio effects and a score display! Stay tuned!
Comments
Please log in or sign up to comment.