Skip to content

Instantly share code, notes, and snippets.

@glassus
Created November 17, 2020 08:34
Show Gist options
  • Save glassus/b7dbabd7e91cb848cac6f210e0b9e677 to your computer and use it in GitHub Desktop.
Save glassus/b7dbabd7e91cb848cac6f210e0b9e677 to your computer and use it in GitHub Desktop.
from microbit import *
from random import randint
a = randint(0,4)
b = randint(0,4)
chrono = running_time()
display.set_pixel(a,b,9)
i = 12
while True:
if running_time() - chrono > 10*1000 :
display.clear()
display.show(Image.SAD)
break
x = i % 5
y = i // 5
display.set_pixel(x,y,9)
if button_a.was_pressed():
display.set_pixel(x,y,0)
i = i - 1
if i < 0 :
i = 0
if button_b.was_pressed():
display.set_pixel(x,y,0)
i = i + 1
if i > 24 :
i = 24
if x == a and y == b :
display.clear()
display.show(Image.HAPPY)
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment