2024-01-13 19:55:47 +01:00
|
|
|
#!/usr/bin/python3
|
2024-01-14 13:48:08 +01:00
|
|
|
#import os
|
2024-01-15 20:38:06 +01:00
|
|
|
from tengine.main import *#ty,tx,scene.clear,genscene,strscene,change_char,bg_char
|
2024-01-13 19:55:47 +01:00
|
|
|
from pynput import keyboard
|
|
|
|
from time import sleep
|
2024-01-15 20:38:06 +01:00
|
|
|
from physics.parabelfunc import berechneflugbahn
|
2024-01-14 13:48:08 +01:00
|
|
|
import ascii
|
2024-01-14 22:36:39 +01:00
|
|
|
import random
|
2024-01-13 19:55:47 +01:00
|
|
|
|
|
|
|
def on_press(key):
|
2024-01-14 13:48:08 +01:00
|
|
|
global key_space
|
2024-01-13 19:55:47 +01:00
|
|
|
if key == keyboard.Key.space:
|
2024-01-14 13:48:08 +01:00
|
|
|
key_space = True
|
2024-01-13 19:55:47 +01:00
|
|
|
|
|
|
|
|
|
|
|
def on_release(key):
|
2024-01-14 13:48:08 +01:00
|
|
|
global running,key_space
|
|
|
|
if key == keyboard.Key.space:
|
|
|
|
key_space = False
|
2024-01-13 19:55:47 +01:00
|
|
|
if key == keyboard.Key.esc:
|
|
|
|
# Stop listener
|
|
|
|
running = "finito"
|
|
|
|
|
2024-01-14 13:48:08 +01:00
|
|
|
key_space = None
|
2024-01-13 19:55:47 +01:00
|
|
|
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
|
|
|
listener.start()
|
|
|
|
|
|
|
|
txhalb = int(tx / 2)-2
|
|
|
|
wobble_speed = 0.01
|
|
|
|
wobble_pos = 0
|
|
|
|
wobble_way = "right"
|
|
|
|
points = 0
|
2024-01-14 13:48:08 +01:00
|
|
|
startscreen = True
|
2024-01-13 19:55:47 +01:00
|
|
|
running = True
|
2024-01-14 22:36:39 +01:00
|
|
|
if not ty >= 11 :
|
|
|
|
running = False
|
|
|
|
print("please resize you teerminal over 11 lines")
|
2024-01-13 19:55:47 +01:00
|
|
|
|
2024-01-14 13:48:08 +01:00
|
|
|
if __name__ == "__main__" and running == True:
|
2024-01-15 20:38:06 +01:00
|
|
|
scene = tengine()
|
|
|
|
scene.set_block(ascii.logo,[0,int(tx/2-21)])
|
2024-01-14 13:48:08 +01:00
|
|
|
|
|
|
|
while startscreen == True:
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.set_block(ascii.start_screen_text,[ty,int(tx/2-5)])
|
|
|
|
scene.print()
|
2024-01-14 13:48:08 +01:00
|
|
|
sleep(0.2)
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.clear()
|
2024-01-14 22:36:39 +01:00
|
|
|
if key_space == True:
|
|
|
|
while not key_space == False:
|
|
|
|
startscreen = False
|
|
|
|
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.viereck([ty,int(tx/2-4)],11,1," ")
|
|
|
|
scene.print()
|
2024-01-14 13:48:08 +01:00
|
|
|
sleep(0.2)
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.clear()
|
2024-01-14 13:48:08 +01:00
|
|
|
if key_space == True:
|
|
|
|
while not key_space == False:
|
|
|
|
startscreen = False
|
|
|
|
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.bg_char(" ")
|
|
|
|
scene.set_block(scene,ascii.cowsay,[int(ty/2)-2,int (tx/2)-12])
|
2024-01-14 22:36:39 +01:00
|
|
|
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
|
|
|
|
cowlistlength = len(cows)
|
2024-01-15 20:38:06 +01:00
|
|
|
cow = "#" #cows[random.randint(0, cowlistlength - 1)]
|
|
|
|
scene.clear()
|
|
|
|
#scene[ty][tx] ### 2zeichen kuhh mach probleme
|
2024-01-14 13:48:08 +01:00
|
|
|
while running == True:
|
|
|
|
wobl = "-" * (tx - wobble_pos - 5)
|
|
|
|
wobr = "-" * wobble_pos
|
2024-01-14 22:36:39 +01:00
|
|
|
wobbl = f"{wobr}{cow}{wobl}"
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.set_block(" " * txhalb+"↓",[ty-1,0])
|
|
|
|
scene.set_block(f"[{wobbl}]",[ty,0])
|
|
|
|
scene.print()
|
2024-01-14 13:48:08 +01:00
|
|
|
if wobble_pos > txhalb:
|
|
|
|
wobble_site = "left"
|
2024-01-13 19:55:47 +01:00
|
|
|
else:
|
2024-01-14 13:48:08 +01:00
|
|
|
wobble_site = "right"
|
|
|
|
|
|
|
|
if wobble_way == "right":
|
|
|
|
wobble_pos += 1
|
|
|
|
if wobble_site == "right":
|
|
|
|
points += 1
|
|
|
|
else:
|
|
|
|
points -= 1
|
2024-01-13 19:55:47 +01:00
|
|
|
else:
|
2024-01-14 13:48:08 +01:00
|
|
|
wobble_pos -= 1
|
|
|
|
if wobble_site == "right":
|
|
|
|
points -= 1
|
|
|
|
else:
|
|
|
|
points += 1
|
2024-01-13 19:55:47 +01:00
|
|
|
|
2024-01-14 13:48:08 +01:00
|
|
|
if wobble_pos >= tx - 5:
|
|
|
|
wobble_way = "left"
|
|
|
|
elif wobble_pos == 0:
|
|
|
|
wobble_way = "right"
|
|
|
|
|
|
|
|
sleep(wobble_speed)
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.clear()
|
2024-01-14 13:48:08 +01:00
|
|
|
|
|
|
|
if key_space == True:
|
|
|
|
break
|
|
|
|
points_prozent = int((points/txhalb)*100)
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.clear()
|
2024-01-14 22:36:39 +01:00
|
|
|
for a in range(int(points*2)-2):
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.set_block("-"*a+cow,[0,0])#🐄️
|
|
|
|
scene.set_block(str(points_prozent)+"%",[1,int(tx/2-2)])
|
|
|
|
scene.print()
|
2024-01-14 13:48:08 +01:00
|
|
|
sleep(0.01)
|
2024-01-15 20:38:06 +01:00
|
|
|
scene.clear()
|
|
|
|
scene.print()
|
2024-01-13 19:55:47 +01:00
|
|
|
|
2024-01-15 20:38:06 +01:00
|
|
|
exit()
|
2024-01-13 19:55:47 +01:00
|
|
|
|
2024-01-15 20:38:06 +01:00
|
|
|
xsteps = int((tx+2)/2) #20#xmax
|
|
|
|
xmax = tx-1 #termsize_xy[0] - 1
|
|
|
|
ymax = ty #termsize_xy[1]
|
|
|
|
ymin = 0
|
|
|
|
xmin = 0
|
|
|
|
startwinkel = 70#+180
|
|
|
|
startgeschwindigkeit = 30
|
|
|
|
starthoehe = 0#int(ty/2)
|
|
|
|
####
|
|
|
|
## needed for erasing old position
|
|
|
|
|
|
|
|
## Call the function, which calculates the coordinates)
|
|
|
|
ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=1, xstep=2)
|
|
|
|
#
|
|
|
|
## here we draw the cow
|
|
|
|
xold = xmin
|
|
|
|
yold = ymin
|
|
|
|
x = xmin
|
|
|
|
y = xmin
|
|
|
|
for count in range(2, len(ergebnis), 2):
|
|
|
|
xold, yold = x, y
|
|
|
|
x, y = ergebnis[count], ergebnis[count + 1]
|
|
|
|
set_block(scene,"@",[x, y])
|
|
|
|
sleep(0.1)
|
|
|
|
set_block(scene,"-",[xold, yold]) #☁️
|
|
|
|
scene.print()
|