
💤
Posts tagged with :zzz:


























#import import random import time #Starting Code text = ("shaking.... \n") answers = ["Yes.", "No.", "Absolutely!", "No waaaayyy!"] #the games code def game(): print("") print("Welcome to the Magic 8 Ball game—use it to answer your questions...") time.sleep(1) print("Ask me for any advice and I'll help you out.") time.sleep(1) question = input("Type in your question and then press 'Enter' for an answer: ") print("") for i in range(4): for char in text: print(char, end='', flush=True) time.sleep(0.1) print(" ") choice=random.randint(1,4) time.sleep(2) choice = random.choice(answers) for i in range(1): for char in choice: print(char, end='', flush=True) time.sleep(0.1) print("") #Game Ending while True: game() print("") play_again = input("Do you want to play again? (yes/no): ") if play_again.lower() != "yes": print("Bye then...") print("") break




async def main(): _display = Display() _vcanvas = vcanvas.vCanvas(128, 64, lambda data: _display.render(data)) render_task = uasyncio.create_task(_vcanvas.render()) frame = vcanvas.Frame(_vcanvas, width=64, height=32, background_color=1, ax=0.5, ay=0.5, position_type="scale", x=0.5, y=0.5) label = vcanvas.TextLabel(frame, text="Welcome!", text_size=1, ax=0.5, ay=0.5, position_type="scale", x=0.5, y=0.5) amogus = 1 try: while True: await uasyncio.sleep(1) print("Looping", utime.ticks_ms()) Pin("LED", Pin.OUT).toggle() if amogus == 0: frame.x = 0.25 frame.y = 0.25 label.text = "Welcome!" amogus = 1 elif amogus == 1: frame.x = 0.75 frame.y = 0.75 label.text = "Welcome" amogus = 0 finally: render_task.cancel() try: await render_task except uasyncio.CancelledError: print("Cancelled render task") uasyncio.run(main())

















