BBC micro:bit – Tetris Game

For this challenge we are creating a game of Tetris to play on the BBC micro:bit.

The game will be based on the following four shapes:
microbit-tetris-shapes

The game will use the following inputs:

  • Button A: Move current brick to the left
  • Button B: Move current brick to the right
  • Button A and B simultaneously: Rotate current brick clockwise

Video Demo


The game will use the LED screen which consists of a 5×5 grid of 25 LEDs.
Each LED can be on (value: 9 for maximum brightness) or Off (value: 0)
The side/borders of the grid will note be displayed.

The Python code will use 2-dimension arrays (list of lists in Python) to store the main grid (7×5) and the current brick (2×2)
microbit-tetris-grid

microbit-tetris-4-shapes

microbit-tetris-grid-LEDs
To test this code you will need to use the Python Editor from the micro:bit website.
micro-bit-logo

Python Code

Note: When testing this code, you may want to remove some of the #annotations especially if your micro:bit returns a “memory full” error.

Share Button
Posted in BBC micro:bit, Computer Science, Python - Advanced, Python Challenges Tagged with:

Our Latest Book

Follow this blog