''' Mission 9 Remix 3A Button A will spin the arrow, button B will roll the die Used only one function per option. Instead of getting a random value as the final, get a random number for the loop and the last arrow or number is the final one showing. NOTE: I used display.print() statements to keep it simple. The output can look better if display.draw_text() statements are used instead. Also Used button D to end game ''' from codex import * import random from time import sleep # Introduction to program def intro(): # Intro display.print("GAMING") display.print("PROGRAM") display.print("A = spin") display.print("B = roll") display.print("") display.print("D = Stop") while True: if buttons.was_pressed(BTN_A) or buttons.was_pressed(BTN_B): break # One function for random die roll # inputs random number for loop # generates random number to display until loop ends def show_random_die(count): #display.clear() loops = 0 delay = 0.04 while loops < count: display.clear() number = random.randrange(1, 7) display.print(" ", scale=8) # Moves text down from top corner display.print(number, random.choice(COLOR_LIST), scale=10) sleep(delay) delay = delay + 0.005 loops = loops + 1 # One function or arrow spinning # inputs random number for loop # loop goes that random number and stops, displaying final arrow def spin_animation(count): index = 0 delay = 0.04 loops = 0 while loops < count: display.show(pics.ALL_ARROWS[index]) sleep(delay) delay = delay + 0.005 index = index + 1 if index == 8: index = 0 loops = loops + 1 # Main program intro() while True: if buttons.was_pressed(BTN_A): # generate random # of arrow spins, display final arrow count = random.randrange(10, 30) spin_animation(count) if buttons.was_pressed(BTN_B): # generate random # of dice rolls, display final roll count = random.randrange(5, 10) show_random_die(count) if buttons.was_pressed(BTN_D): break # Ending display.clear() display.print("DONE", scale=5)