cowyeet_terminal/v1.py

78 lines
1.6 KiB
Python
Raw Normal View History

2023-11-04 22:36:22 +01:00
#!/usr/bin/python3
import os
2024-01-17 19:15:14 +01:00
from tengine.main import ty,tx,clear
2023-11-04 22:36:22 +01:00
from pynput import keyboard
from time import sleep
def on_press(key):
global running
if key == keyboard.Key.space:
running = False
2023-11-06 16:13:41 +01:00
2023-11-04 22:36:22 +01:00
def on_release(key):
global running
if key == keyboard.Key.esc:
# Stop listener
running = "finito"
2023-11-06 16:13:41 +01:00
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
2023-11-04 22:36:22 +01:00
listener.start()
txhalb = int(tx / 2)-2
2023-11-04 22:36:22 +01:00
wobble_speed = 0.01
wobble_pos = 0
wobble_way = "right"
points = 0
2023-11-04 22:36:22 +01:00
running = True
while running == True:
2023-11-06 16:13:41 +01:00
wobl = "-" * (tx - wobble_pos - 5)
wobr = "-" * wobble_pos
2023-11-04 22:36:22 +01:00
wobbl = f"{wobr}🐄️{wobl}"
2023-11-06 16:13:41 +01:00
print(" " * txhalb, "")
2023-11-04 22:36:22 +01:00
print(f"[{wobbl}]")
print(wobble_pos)
print(points)
print(tx)
print(txhalb)
if wobble_pos > txhalb:
wobble_site = "left"
else:
wobble_site = "right"
2023-11-04 22:36:22 +01:00
if wobble_way == "right":
wobble_pos += 1
if wobble_site == "right":
points += 1
else:
points -= 1
2023-11-04 22:36:22 +01:00
else:
wobble_pos -= 1
if wobble_site == "right":
points -= 1
else:
points += 1
2023-11-04 22:36:22 +01:00
if wobble_pos >= tx - 4:
2023-11-04 22:36:22 +01:00
wobble_way = "left"
elif wobble_pos == 0:
wobble_way = "right"
2023-11-04 22:36:22 +01:00
sleep(wobble_speed)
clear()
if running == "finito":
exit()
#tx halb = max points #in ausgerechneten bruch und an in bruch mit nenner 100 ergibt zähler mit punktewert
2023-11-04 22:36:22 +01:00
for a in range(int(points*2)):
2023-11-06 16:13:41 +01:00
print("-" * a + "🐄️", end="\r")
2023-11-04 22:36:22 +01:00
sleep(0.01)
points = int((points/txhalb)*100)
print("\n", points, "%")