Tag: microbit

Starbit Commander II

Well on my quest to learn python, I poked and peeked around on the web of inters. And came across some nice sites about the micro:bits, projects and coding.

One site inspired me to create a python version of Starbit Commander. This site is home to a lot of projects of Derek Graham. Next to Micro:bit bits, he has a lot of other stuff too on his site.

But why remake of Starbit Commander? Derek has this nice example of “Tiny Astroids”, which resembled a lot like Starbit Commander. And he created it in Python… sooo.. mine Starbit Commander should get a python version too… In this little gem from Derek, he created a really really nice piece of code that animated an explosion on this 5×5 led display. I loved it. And although I wanted to create Starbit from scratch in OO, I really wanted to adopt this nice little tiny explosion.. So I contacted Derek via twitter, asked if he agreed me borrowing his explosion-code. we had a short but very nice chat on twitter and he agreed for the code to be reuse in Starbit Commander. Thanks Derek!

Well, I wanted to test and learn more python and also OO in python. So I decided to try to make Starbit Commander in an OO-style. I have no experience in this but I think (as far as I can tell) this is an OO-version of the game now. Derek mentioned on micro:bit V1’s coding OO would let you ran into out of memory errors. I haven’t seen them on the microbit V2 with Starbit Commander. (Now I’m worried if I did a proper OO-coding style ;-0)

I differed a bit from the original Starbit code. While de MakeCode version has power-ups to collect, in this python-version I decided to skip that and make the astroidfield a bit more challenging by starting slow and easy and ending fast and astroid-crowded. Giving you more and more bonus score along the way you go.

This code can by found here. And watch that explosion… Thanks again Derek Graham!


Twitter: @marc0janssen

Micro:bit Fireflies

My first attempt to write some (micro)Python code. Fireflies. This leds simulate fireflies in the air…

btw. I found that display.get_pixel does not return the correct value for the brightness of a led on a micro:bit. I created this function to correct this behavior in the code (fixPixelBug).

from microbit import *
import random

# This fucntions fixes the "display.get_pixel" bug.
# a full bright led does not return a "9" but a "255".
def fixPixelBug(brightness):
    if brightness == 4:
        return 3
    elif brightness == 8:
        return 4
    elif brightness == 16:
        return 5
    elif brightness == 32:
        return 6
    elif brightness == 64:
        return 7
    elif brightness == 128:
        return 8
    elif brightness == 255:
        return 9
        return brightness

while True:

    brightness = random.randint(1, 9)
    x = random.randint(0, 4)
    y = random.randint(0, 4)
    if display.get_pixel(x, y) == 0:
        display.set_pixel(x, y, brightness)

    for fireflies in range(0, 5):
        x = random.randint(0, 4)
        y = random.randint(0, 4)

        if fixPixelBug(display.get_pixel(x, y)) > 0:
            display.set_pixel(x, y, fixPixelBug(display.get_pixel(x, y)) - 1)



Twitter: @marc0janssen

Simple Simon Says

The game Simon in the late 70’s was maybe the first “computer” game I played. Well maybe it was a real computer. I was just a kid, but the game stayed always with me. In my mind that is. The game was from a friend and we played it for ages.

Now with the Micro:bit I wanted to revive this memory and use the Micro:bit as a vehicle to get this to life again. Below is my make code attempt. I used an Micro:bit version2 for this.

This Simon listens to Buton A, Button B, Button C (the touch sensitive logo), Button D (= Button A+B).

It was fun to create and a good way to set me off with the possibilities of the Micro:bit…

To edit this repository in MakeCode.


Twitter: @marc0janssen

Starbit Commander

This game is my first coding for The BBC Micro:bit. The goal is to have a nice target to practice and learn microPython on this device. But first I wanted to have a go on the makeCode editor for the Micro:bit.

I made this simple little game. Flying a spaceship through an astroidfield. Sometimes a blinking power-up will appear. This gives a the advance to survive an astroid collision. Catching two power-ups will destroy all astroids in the field. Astroids will speed up in time but slow down if a double power-up is acquired.

To edit this repository in MakeCode.


Twitter: @marc0janssen