Play Multiplayer Tetris on a Pair of ESP32-Powered LED Matrices
This take on the classic retro game Tetris allows two players to interactively compete for a chance to win while using 64x64 matrices.
Coming up with the idea
The beloved video game Tetris has existed in many forms since 1985 when it was first released, and being that it is the third-most sold video game ever with a total of 100 million copies, many more innovations are to be expected. After receiving a pair of 64x64 RGB LED matrices, Instructables user berlingozzo had the idea to build a portable battery-powered console that could run at least one game. After realizing that Tetris would be an ideal candidate, he then thought of how a second console could be paired for use in a multiplayer scenario, all while taking advantage of open source hardware/software.
Required components
The most important aspect of these two Tetris consoles is the how they utilize large LED matrices to display the game and other information. Each one is a 64x64 pixel panel which relies on the common HUB75 LED driver IC to drive a total of 4,096 LEDs spread across a 192x192mm area. Controlling the panel is an ESP32 board which was selected due to its speed, internal storage capacity, and the ability for direct, wireless communication with another ESP32 via the ESPNow protocol. Players are able to input commands via a set of six buttons- three on each half- while a pair of buzzers provide basic music and sound effects.
Creating the cases
The parts of each housing were formed by first 3D printing a set of three distinct pieces: the tall outer perimeter, a middle support, and the smooth back which all come together to form a rigid structure and keep everything in-place. Next, because of how the LED matrices allow pixels to bleed into each other, Berlingozzo had to design and carefully print a grid of tiny separators to add that classic pixelated look. The final top piece was cut from a sheet of translucent black acrylic to give a sleek, modern look. In total, the process took over 24 hours to complete.
Wiring it all together
Once all of the components had been gathered, Berlingozzo began the painstaking process of hand-soldering the ribbon cable to the correct pins on the ESP32 board before moving onto attaching each of the six buttons. Several inline resistors had to be included with the buzzers as current limiters due to how loud they could get, and the soldering job wrapped up with connecting the AA battery pack to the panel and other electronics.
How to add multiplayer communication
Most of the game operates as one would expect, with upcoming pieces on the right, a score tracker on the left, and the central piece-dropping area in the middle. But because Berlingozzo wanted to make his take on Tetris unique by adding multiplayer support, the code also had to become more complex. As mentioned earlier, the two consoles communicate over WiFi via the ESPNow direct-connection protocol, and the data sent on each tick includes the opponent's current height and if any lines have been cleared. Clearing two, three, or four lines simultaneously will cause the opponent to receive one, two, or three lines of garbage, respectively for an added challenge.
Playing Tetris
The ability to play this highly interactive and social spin on the classic Tetris format is unique, let alone due to how large the display is. By including persistent settings and over-the-air (OTA) updates via WiFi, users can easily enjoy an enhanced experience over the typical DIY console. More information can be found here in Berlingozzo's Instructables write-up, and you can watch his demonstration video below!