''' Day 3 Remix - Beginner Level ''' from codex import * from time import sleep import random delay = 1 def one_roll(color): display.fill_circle(125, 125, 30, color) def two_roll(color): display.fill_circle(50, 50, 30, color) display.fill_circle(200, 200, 30, color) def three_roll(color): display.fill_circle(50, 50, 30, color) display.fill_circle(125, 125, 30, color) display.fill_circle(200, 200, 30, color) def four_roll(color): display.fill_circle(200, 50, 30, color) display.fill_circle(50, 200, 30, color) two_roll(color) def five_roll(color): four_roll(color) one_roll(color) def six_roll(color): four_roll(color) display.fill_circle(50, 125, 30, color) display.fill_circle(200, 125, 30, color) def display_roll(num, color): if num == 1: one_roll(color) elif num == 2: two_roll(color) elif num == 3: three_roll(color) elif num == 4: four_roll(color) elif num == 5: five_roll(color) else: six_roll(color) # Intro display.draw_text("Roll Dice", scale=3, x=35, y=80) display.draw_text("Program", scale=3, x=35, y=120) display.draw_text("Press A to roll", scale = 2, x=35, y=170) display.draw_text("Press B to quit", scale = 2, x=35, y=185) sleep(delay) while True: if buttons.was_pressed(BTN_A): display.clear() #audio.mp3("sounds/Die_Roll.mp3") display.draw_text("Rolling", scale=3, x=35, y=80) sleep(delay-0.2) display.draw_text("Rolling", scale=3, x=50, y=120) sleep(delay-0.4) display.clear() display.draw_text("Rolling", scale=3, x=85, y=160) sleep(delay-0.7) bounces = 5 while bounces > 0: display.clear() color = random.choice(COLOR_LIST) display.draw_rect(3, 3, 236, 236, color) num = random.randrange(6) + 1 color = random.choice(COLOR_LIST) display_roll(num, color) sleep(0.2) bounces = bounces - 1 sleep(delay) display.clear() if buttons.was_pressed(BTN_B): break display.draw_text("DONE", scale=5, color=RED, x=55, y=100) sleep(delay*2) display.clear()