''' Mission 9 - Game Spinner The program will act as a digital arrow spinner. It introduces user-defined functions, a parameter and argument. It uses variables for the index, controlling a loop, and varying the delay (speed of the arrow spinning). It also uses a logical operator (or) for buttons pressed. ''' from codex import * import random from time import sleep # Select a random arrow from the built-in list def show_random_arrow(): num = random.randrange(8) display.show(pics.ALL_ARROWS[num]) # Animation that shows the arrows spinning def spin_animation(count): delay = 0.05 index = 0 loops = 0 while loops < count: my_arrow = pics.ALL_ARROWS[index] display.show(my_arrow) sleep(delay) delay = delay + 0.005 loops = loops + 1 index = index + 1 if index == 8: index = 0 # == MAIN PROGRAM == while True: if buttons.is_pressed(BTN_A) or buttons.is_pressed(BTN_B): spin_animation(20) show_random_arrow()