2023-10-20 20:24:46 +02:00
|
|
|
#!/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():
|
2023-10-31 10:31:45 +01:00
|
|
|
if os.name == "nt":
|
|
|
|
os.system("cls")
|
|
|
|
else:
|
|
|
|
os.system("clear")
|
2023-10-20 20:24:46 +02:00
|
|
|
|
|
|
|
|
|
|
|
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.")
|