from codex import * from time import sleep import random nouns = ["hill", "tuffet", "clock"] verbs = ["broke", "ran", "sat"] animals = ["spider", "mouse", "sloth"] names = ["Jack", "Jill", "Miss"] def bright_pixels(): red = random.randrange(0, 255) green = random.randrange(0, 255) blue = random.randrange(0, 255) color = (red, green, blue) pixels.set(0, color) pixels.set(1, color) pixels.set(2, color) pixels.set(3, color) def disco_pixels(): # to do for pixel in range(4): red = random.randrange(0, 255) green = random.randrange(0, 255) blue = random.randrange(0, 255) color = (red, green, blue) pixels.set(pixel, color) def random_words(): global name1, name2, noun, verb, animal name1 = random.choice(names) name2 = random.choice(names) noun = random.choice(nouns) verb = random.choice(verbs) animal = random.choice(animals) def jack_and_jill(): display.print(name1 + " and " + name2) display.print("went up a " + noun) display.print("to fetch a pail") display.print("of water.") display.print("") display.print(name1 + " fell down") display.print("and " + verb + " his crown") display.print("and " + name2 + " came") display.print("tumbling after") def hickory_dickory(): display.print("Hickory dickory ") display.print("dock") display.print("The " + animal + " went up") display.print("the " + noun) display.print("The " + noun + " struck 1") display.print("The " + animal + " " + verb + " down") display.print("Hickory dickory ") display.print("dock") def little_miss_muffet(): display.print("Little " + name1 + " Muffet") display.print("sat on a " + noun) display.print("eating her curds") display.print("and whey") display.print("Along came a " + animal) display.print("and sat down ") display.print("beside her") display.print("And " + verb + " " + name1) display.print("Muffet away") def menu(): # Introduction display.print("Welocome to") display.print("Madlibs!", scale=) display.print() display.print("L=Jack & Jill") display.print("R=Hickory Dickory") display.print("A=Little Miss") display.print() display.print("B quit") # === Main program === menu() while True: if buttons.was_pressed(BTN_L): display.clear() bright_pixels() random_words() jack_and_jill() if buttons.was_pressed(BTN_R): display.clear() disco_pixels() random_words() hickory_dickory() if buttons.was_pressed(BTN_A): display.clear() disco_pixels() random_words() little_miss_muffet() if buttons.was_pressed(BTN_B): break display.clear() display.print("Have a good day!")