from codex import * from time import sleep from random import randrange def clover_3(): display.fill_circle(34, 80, 20, GREEN) display.fill_circle(76, 80, 20, GREEN) display.fill_circle(55, 50, 20, GREEN) display.fill_rect(50, 55, 8, 65, GREEN) def clover_4(): display.fill_circle(38, 77, 20, DARK_GREEN) display.fill_circle(72, 77, 20, DARK_GREEN) display.fill_circle(38, 43, 20, DARK_GREEN) display.fill_circle(72, 43, 20, DARK_GREEN) display.fill_rect(50, 50, 8, 75, DARK_GREEN) def make_choice(num, prob): if num < prob: return True else: return False def display_choice(choice): if choice: clover_4() else: clover_3() def flash_pixels(): for i in range(5): pixels.fill(DARK_GREEN) sleep(0.25) pixels.off() sleep(0.1) # -- Main program count = 0 while True: if buttons.was_pressed(BTN_A): display.clear() count = count + 1 num = randrange(100) choice = make_choice(num, 20) display_choice(choice) if choice: text = "Number of Spins: " + str(count) display.draw_text(text, 10, 220, scale=2) flash_pixels() count = 0