Created
May 6, 2019 19:36
-
-
Save descartez/03acd3e89e3072e84147d8fbfb78c95d to your computer and use it in GitHub Desktop.
code club dueling game
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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