microbit Tetris in python

microbit Tetris in python

I’ve finally got round to updating the online microbit python simulator in create.withcode.uk to catch up with some of the amazing new micropython features (such as speech and radio).

To celebrate, here are three different versions of the classic game tetris that you can simulate online in a virtual microbit or download to your device and play.

Microbit tetris in python
microbit tetris in python

First version

The first two¬†tetris games weren’t made by me: the first was made by VivianePons and donated into the public domain after making it at PyCon2016.

It uses the microbit’s accelerometer to sense how much you tilt the device in order to move the blocks left and right. You can play it in the simulator by clicking on the accelerometer tab and changing the X slider left and right.

Second version

The second version of tetris comes from the excellent tutorial at 101 Computing. It uses buttons A and B to move the blocks and you get different shapes that you can rotate by pressing both buttons rather than a single dot:

Which version do you prefer? Can you combine the best bits of both programs? I think it’d be great it you could use the accelerometer like the first version but have the more complex blocks that you can rotate like the second one. Perhaps button A would¬†rotate counter clockwise and button B clockwise. Post a comment with a link to your code if you’re able to improve on either of these projects and thanks to the original authors for sharing their code online.


Update 28/3/2017:

It seems that the second version doesn’t work any more with the current version of micropython for a micro:bit.

Please see below for a version of Tetris I’ve put together that works on both the simulator and an actual device.

There are four different types of blocks that fall down. You can move them by pressing A or B or rotate them by tilting the microbit left or right.

Have fun!