To celebrate our new mascot Dex, we made a hack to build Dex from stone in Minecraft on the Raspberry Pi. With a little bit of hacking we were able to write a Python script that generated Dex in Minecraft. Dex arises from the horizon with stone, one block at a time, with a little Python code. This process could be used to generate any logo or symbol!
How we did it:
1). The first step we took was to reduce Dex down to a pretty small image. Fortunately, he lends himself well to this. We reduced the size and scope down to a 100×100 pixel BMP in black and white.
2). Next, we needed an ASCII file of Dex. To get this, we fed the above image into picascii, which turned our picture of Dex into an ascii file of Dex. We upload our picture of Dex, and we get back a nice text file like this.
3). Finally, we wrote a really simple Python program that opens the text file, and reads it and spits out stone in the shape of Dex. The Python program goes through each line of the ascii file of dex, from the bottom up, and then reads every single character. If the character isn’t blank space, it lays a Minecraft stone down where the non-space character is.
We ran the python script using the command
4). Voila! Dex is built in our virtual world! We put a small delay between each stone laying, so you can watch Dex get built in real time!
You can try it too! We put all the necessary files to make your own Dex in Minecraft up in Github here.
What have you done in Minecraft on the Pi? And even better, how could we use one of our robots with Minecraft on the Pi? Tell us in the comments!