From 5b77a5c61cd7eea10de22999111c07543233f4e4 Mon Sep 17 00:00:00 2001 From: The Wobbler Date: Fri, 20 Oct 2023 20:24:46 +0200 Subject: [PATCH] Dateien nach "/" hochladen --- cowyeet.py | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 cowyeet.py diff --git a/cowyeet.py b/cowyeet.py new file mode 100644 index 0000000..e6021f4 --- /dev/null +++ b/cowyeet.py @@ -0,0 +1,115 @@ +#!/usr/bin/python3 + +import os +from time import sleep +from pynput import keyboard + + +FPS = 60 +BLA_SPEED = 1 + +tx, ty = os.get_terminal_size().columns, os.get_terminal_size().lines +half_tx = round(tx / 2) +bla_pos = 1 +bla_back = False +stop = None +yeet = None +yeet_dist = None + + +def clear(): + os.system("clear") + + +def on_press(key): + global stop + global yeet_dist + + try: + if key == keyboard.Key.space: + if not stop: + stop = bla_pos + + bla_dist = half_tx - bla_pos + + if bla_dist < 0: + bla_dist = 0 - bla_dist + + yeet_dist = tx - 2 - bla_dist * 2 - 10 + + except AttributeError: + # print('special key {0} pressed'.format(key)) + pass + + +def on_release(key): + # print('{0} released'.format(key)) + + if key == keyboard.Key.esc: + # Stop listener + return False + + +def move_bla(): + global bla_pos + global bla_back + + print(" " * (half_tx - 1) + "↓") + print(" " * (bla_pos - 1) + "#") + + if bla_back: + bla_pos -= BLA_SPEED + + else: + bla_pos += BLA_SPEED + + if bla_pos >= tx: + bla_back = True + + elif bla_pos <= 1: + bla_back = False + + +def yeet_cow(): + global yeet + global running + + if not yeet: + yeet = 1 + + print("-" * (yeet - 1) + "🐄️") + + if yeet >= yeet_dist: + running = False + + yeet += 1 + + +def loop(): + clear() + + if not stop: + move_bla() + + else: + yeet_cow() + + sleep(1 / FPS) + + +listener = keyboard.Listener( + on_press=on_press, + on_release=on_release) + +listener.start() + + +running = True + +try: + while running: + loop() + +except KeyboardInterrupt: + clear() + print("Exit.")