Skip to content

Instantly share code, notes, and snippets.

@gabalese
Created July 23, 2016 12:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gabalese/df0fc5884a0853b436366ad97994bbf4 to your computer and use it in GitHub Desktop.
Save gabalese/df0fc5884a0853b436366ad97994bbf4 to your computer and use it in GitHub Desktop.
A simple game of russian roulette played with the bbc:microbit. Reset the device when you "die"
from microbit import *
import random
choices = [1,2,3,4,5,6]
death_number = random.choice(choices)
click_counter = 0
while True:
display.show(Image.ASLEEP)
while not (button_a.is_pressed() or button_b.is_pressed()):
sleep(1)
if button_a.is_pressed() or button_b.is_pressed():
click_counter += 1
if click_counter == death_number:
panic()
else:
display.show(Image.HAPPY)
sleep(2000)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment