Skip to content

Instantly share code, notes, and snippets.

@descartez
Created May 6, 2019 19:36
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 descartez/03acd3e89e3072e84147d8fbfb78c95d to your computer and use it in GitHub Desktop.
Save descartez/03acd3e89e3072e84147d8fbfb78c95d to your computer and use it in GitHub Desktop.
code club dueling game
# Add your Python code here. E.g.
from microbit import *
import random
playing = False
winner = "-"
min_time = 300
max_time = 700
while True:
if button_a.is_pressed() and button_b.is_pressed():
winner = "-"
display.show("3")
sleep(random.randint(min_time, max_time))
display.show("2")
sleep(random.randint(min_time, max_time))
display.show("1")
sleep(random.randint(min_time, max_time))
display.show("0")
playing = True
while playing:
if button_a.is_pressed():
winner = "A"
playing = False
elif button_b.is_pressed():
winner = "B"
playing = False
display.show(winner)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment