Press Space (or A+B on a micro:bit) to keep running.
The game reads one line per update: X,BTN_A,BTN_B at 115200 baud. For two players, put the same code on both boards.
serial.redirectToUSB()
serial.setBaudRate(BaudRate.BaudRate115200)
basic.showIcon(IconNames.Rabbit)
basic.forever(function () {
let a = 0
let b = 0
if (input.buttonIsPressed(Button.A)) {
a = 1
}
if (input.buttonIsPressed(Button.B)) {
b = 1
}
serial.writeLine("" + input.acceleration(Dimension.X) + "," + a + "," + b)
basic.pause(30)
})
from microbit import *
uart.init(baudrate=115200)
display.show(Image.RABBIT)
while True:
x = accelerometer.get_x()
a = 1 if button_a.is_pressed() else 0
b = 1 if button_b.is_pressed() else 0
print("%d,%d,%d" % (x, a, b))
sleep(30)
Tilt steers, A jumps, hold B to duck, press A+B together to pause.
Download the code to each micro:bit (a rabbit appears on its screen when it's running). Plug both in by USB, then click Connect Player 1 and pick the first board, and Connect Player 2 and pick the other one. Use Chrome or Edge, and close the MakeCode tab (or disconnect it there) and any other serial monitor first, because only one page can use a port.