''' Mission 8 Answer Bot Spicy Remix 3BB Create a program that simulates a dice roll. This version adds a sound file for rolling dice and uses a random number instead of a list. ''' from codex import * from time import sleep import random # Instructions display.print("Roll Dice", scale=3) display.print("Program", scale=3) display.print("Press U to start", scale=2) display.print("Press A to roll", scale=2) display.print("Press D to quit", scale=2) # Wait to start while True: if buttons.was_pressed(BTN_U): display.clear() break # Define variables - values don't change sides = 6 delay = 0.5 # Loop until break for repeated rolls while True: # if button is pressed, roll dice if buttons.was_pressed(BTN_A): display.clear() # this sound was uploaded to Codex (optional) audio.mp3("sounds/Die_Roll.mp3") display.draw_text("Rolling", scale=3, x=35, y=80) sleep(delay) display.draw_text("Rolling", scale=3, x=50, y=120) sleep(delay) display.clear() number = random.randrange(sides) # Add one because random numbers are 0 to 5 number = number + 1 display.print(number, scale=20) sleep(delay) if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("DONE", scale=5)