For those Just now joining the micro:bit fun, I am a college professor in game design, and have been involved with various maker and hacker groups for many years. I have been blogging about my experience introducing the micro:bit platform to college students in an intermediate Game Design class where I teach. Their project was to make a multiplayer game, using the micro:bit’s radio library for communication, so the game accounts for space or motion as part of gameplay. Gestures were used to think about the games as spacial instead of the typical keyboard/mouse games they play every day.
I intentionally had the students leave the boards stock, so that shared code could be used as a start-up example for other educators.
The first few weeks of progress can be viewed over several blog posts here:
and the original assignment sheet for the project can be found here:
Most of our students have recovered from the holiday and spent the remaining time working toward a playable version of their game. For sake of reporting to the element14 community, I established an artificial goal of play-testing their projects for today. Their actual semester final (and the due-date for their games) is on December 10th.
Despite the Micro:bit giveaway being over, I have confirmed with the students that the best games will be documented, packaged and archived here, for other educators, clubs and hobbyists to try out. They're excited to put some useful code out into the world!
Note that since the previous blogs, some ideas have drastically simplified. This is common in a development cycle with a hard deadline.
Group A had major changes since my last blog, and still have a bit to go. Their overall idea involves playing one of a group of characters who must forage for food to survive. Foraging may result in food that increases health, or encountering another player who you must duel for survival. Last person standing lives!
I’ve attached two microbit.py programs that I helped them write, to sort out the duel mechanic.
One code base is a server, that uses the radio library to communicate timing and outcomes to the players. The other code needs to have a single line changed, but can be used for as many players as you have micro:bits. Everyone waits for the server’s A button to be pressed. At that moment each micro:bit user sees a countdown, and must strike (swing the accelerometer like a sword). The first to succeed is then transmitted to all players by the server. This is a pretty fun group demo game by itself!
Server Code [DuelServer.py] & Client Code [DuelClient.py] inline at the bottom of the post below.
Group B have developed a game where you are a king in charge of an army.
You arm the four walls of your camp with soldiers, and then take turns attacking the others. They made use of the pixel images to create flags for each team, and used a clever tilt AND press combination. It feels very visual, but it does have an awkward feeling when you tilt forward to arm the North wall of your camp.
The group still has some work to do before a final release, as their game is split between two coders. Their biggest challenge has been keeping the code concise, as redundant loops have made the code size a bit too big for the device. We tested the game mechanic across two devices, which approximates the feeling, but prevents the game from being playable. I have high hopes for their finish.
Group C have been purrring along with their cat and mouse game. (sorry, the pun was right there.)
This was the most well received of the three games, and was very playable despite a few bugs. On powering the micro:bits (up to 10), you are assigned as one of 9 mice or a cat. The cat then pauses for a few minutes as the mice run and hide. Players tilt their micro:bit up, down, left or right to navigate through a virtual 25x25 pixel space. Each player uses the 5x5 led array as a window map of their world (mice flash, cat is constant). Each caught mouse produces a skull on the screen and the cat continues to play.
Ultimately, team C will try to implement a timer so the mice could “win” if the cat doesn’t catch them during a specific countdown. Timers have been a real problem in the micro:bit, as there are no background tasks on the micro:bit. Running an iterated counter spools to the end of a variable range too quickly (these processors are fast!), meaning that two variables must be used. We’ve found a lot of discussion on this through the forums and documentation online. I agree that the average youthful user shouldn’t need to worry about threaded tasks, but even a seven year old will want a timer! Hopefully, we see a timer function in the future firmware for this device.
I’m thrilled at the results my students produced, and as mentioned before, will post the best examples here in a few weeks. The cost and learning curve for this device have been incredible, and I will use these in future classes given some additional circuitry (ie: sound). I also do some work with younger kids, and will definitely work the micro:bits into that curriculum as well. Thanks to @element14 for the opportunity!
#Dual Client #Change Reporting MSG on line 7, for each micro:bit playing 1st player 'A', 2nd = 'B', etc.. #requires one microbit running the "DuelServer.hex" code. from microbit import * import radio radio.on() #turn on radio ID = 'A' while True: #wait for 'go' from server display.show(ID) msg= radio.receive() if msg == 'go': break #countdown display.show('3') sleep(1000) display.show('2') sleep(1000) display.show('1') sleep(1000) display.show('!') while not accelerometer.was_gesture("shake"): #wait for gesture display.show(Image.TRIANGLE) radio.send(ID) display.show(Image.HEART) sleep(2000) while True: #receive winner from server msg= radio.receive() if msg is not None: display.show(msg)
#Dual Server - works with any small number of clients from microbit import * import radio radio.on() while True: #wait for A button to start game, Someone must press the "A" on the server to sync the countdown. display.show(Image.SWORD) if button_a.was_pressed(): radio.send('go') break #countdown display.show('3') sleep(1000) display.show('2') sleep(1000) display.show('1') display.show(Image.DIAMOND) while True: #wait to receive winner (first msg received) msg = radio.receive() if msg is not None: break while True: #Send winner to all players radio.send(msg) display.show(msg) sleep(1000)