''' Mission 8 Answer Bot Spicy Remix 3 Create two lists: one has pictures, colors and text. The other list is pictures uploaded to the codex. -- will not display; use your own uploaded images. -- the point here is that the lists can be different -- it could also be sounds, etc. Use BTN_A and BTN_B to select which list to use. Use BTN_L and BTN_R to scroll, and BTN_U for random. Use BTN_D to quit. If the lists are the same lengths, you can use a single variable (constant) for the last index. If the lists are different lengths, you will need to change the value of the last index. ''' from codex import * import random from time import sleep # my list of JPG pics uploaded to Codex my_pics = ["pics/doggie.jpg", "pics/goldfish.jpg", "pics/kitty.jpg", "pics/piggie.jpg", "pics/rabbits2.jpg", "pics/tortoise.jpg", "pics/my_loves.jpg", "pics/sunDevil.jpg", "pics/firia.jpg", "pics/kyoto.jpg", "pics/christmas.jpg"] # My list of pictures and text my_list = ["The odds are yes", "It is not in the stars", GREEN, RED, BLUE, YELLOW, ORANGE, "Go for the gold!", "Today is your day", "Stay home and read", "Have an adventure", pics.HEART, pics.TIARA, pics.PLANE, pics.HAPPY] # Introduction display.print("A=Pictures", scale=3) display.print("B=Items", scale=3) display.print("L=scroll<-", scale=3) display.print("R=scroll->", scale=3) display.print("U=random", scale=3) display.print("D=quit", scale=3) # Hold the instructions until A or B is pressed # Alternatively, you can just assign values to # the_list and the_last without waiting for a button press while True: if buttons.was_pressed(BTN_A): the_list = my_pics the_last = len(my_pics) index = 0 break if buttons.was_pressed(BTN_B): the_list = my_list the_last = len(my_list) index = 0 break # Continue to show images until D is pressed while True: # assign value to item from the chosen list item = the_list[index] # check to see which list is chosen to # correctly display the item if the_list == my_pics: display.draw_jpg(item) else: if type(item) == tuple: display.fill(item) else: display.show(item) # Scroll left if buttons.was_pressed(BTN_L): index = index - 1 if index < 0: index = the_last - 1 # Scroll right if buttons.was_pressed(BTN_R): index = index + 1 if index >= the_last: index = 0 # Get random item if buttons.was_pressed(BTN_U): index = random.randrange(the_last) # Select the first list if buttons.was_pressed(BTN_A): the_list = my_pics the_last = len(my_pics) if index >= the_last: index = the_last - 1 # Select the last list if buttons.was_pressed(BTN_B): the_list = my_list the_last = len(my_list) if index >= the_last: index = the_last - 1 if buttons.was_pressed(BTN_D): break # Ending message display.clear() display.print("Thanks", scale=5)