alles mal in die engine gepumpt
This commit is contained in:
parent
d4aa1c12bb
commit
48634a0926
4 changed files with 110 additions and 101 deletions
Binary file not shown.
|
@ -98,7 +98,7 @@ if __name__ == "__main__":
|
||||||
ymin = 0
|
ymin = 0
|
||||||
xmin = 0
|
xmin = 0
|
||||||
startwinkel = 34
|
startwinkel = 34
|
||||||
startgeschwindigkeit = 60
|
startgeschwindigkeit = 20
|
||||||
starthoehe = 0
|
starthoehe = 0
|
||||||
schlafzeit = 0.05
|
schlafzeit = 0.05
|
||||||
###
|
###
|
||||||
|
|
Binary file not shown.
209
v2.py
209
v2.py
|
@ -1,34 +1,28 @@
|
||||||
#!/usr/bin/python3
|
#!/usr/bin/python3
|
||||||
import os
|
#import os
|
||||||
from tengine.main import *#ty,tx,clear,genfeld,strfeld,change_char,bg_char
|
from tengine.main import *#ty,tx,clear,genfeld,strfeld,change_char,bg_char
|
||||||
from pynput import keyboard
|
from pynput import keyboard
|
||||||
from time import sleep
|
from time import sleep
|
||||||
from physics.parabelfunc import berechneflugbahn
|
from physics.parabelfunc import berechneflugbahn
|
||||||
import random
|
import ascii
|
||||||
|
#import random
|
||||||
|
|
||||||
#def clear():
|
|
||||||
# if os.name == "nt":
|
|
||||||
# os.system("cls")
|
|
||||||
# else:
|
|
||||||
# os.system("clear")
|
|
||||||
|
|
||||||
|
|
||||||
def on_press(key):
|
def on_press(key):
|
||||||
global running
|
global key_space
|
||||||
if key == keyboard.Key.space:
|
if key == keyboard.Key.space:
|
||||||
running = False
|
key_space = True
|
||||||
|
|
||||||
|
|
||||||
def on_release(key):
|
def on_release(key):
|
||||||
global running
|
global running,key_space
|
||||||
|
if key == keyboard.Key.space:
|
||||||
|
key_space = False
|
||||||
if key == keyboard.Key.esc:
|
if key == keyboard.Key.esc:
|
||||||
# Stop listener
|
# Stop listener
|
||||||
running = "finito"
|
running = "finito"
|
||||||
|
|
||||||
|
key_space = None
|
||||||
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
listener = keyboard.Listener(on_press=on_press, on_release=on_release)
|
||||||
|
|
||||||
listener.start()
|
listener.start()
|
||||||
|
|
||||||
txhalb = int(tx / 2)-2
|
txhalb = int(tx / 2)-2
|
||||||
|
@ -36,93 +30,108 @@ wobble_speed = 0.01
|
||||||
wobble_pos = 0
|
wobble_pos = 0
|
||||||
wobble_way = "right"
|
wobble_way = "right"
|
||||||
points = 0
|
points = 0
|
||||||
|
startscreen = True
|
||||||
running = True
|
running = True
|
||||||
while running == True:
|
|
||||||
wobl = "-" * (tx - wobble_pos - 5)
|
if __name__ == "__main__" and running == True:
|
||||||
wobr = "-" * wobble_pos
|
feld = genfeld()
|
||||||
wobbl = f"{wobr}🐄️{wobl}"
|
feld = change_block(feld,ascii.logo,[1,int(tx/2-21)])
|
||||||
print(" " * txhalb, "↓")
|
|
||||||
print(f"[{wobbl}]")
|
while startscreen == True:
|
||||||
print(wobble_pos)
|
feld = change_block(feld,ascii.start_screen_text,[10,int(tx/2-5)])
|
||||||
print(points)
|
print(strfeld(feld))
|
||||||
print(tx)
|
sleep(0.2)
|
||||||
print(txhalb)
|
feld = viereck(feld,[11,int(tx/2-4)],11,1," ")
|
||||||
|
print(strfeld(feld))
|
||||||
|
sleep(0.2)
|
||||||
|
clear()
|
||||||
|
if key_space == True:
|
||||||
|
while not key_space == False:
|
||||||
|
startscreen = False
|
||||||
|
|
||||||
if wobble_pos > txhalb:
|
feld = bg_char(feld," ")
|
||||||
wobble_site = "left"
|
#feld = change_block[feld,ascii.cowsay,[int(tx/2-8),int(ty/2-2)]]
|
||||||
else:
|
while running == True:
|
||||||
wobble_site = "right"
|
wobl = "-" * (tx - wobble_pos - 5)
|
||||||
|
wobr = "-" * wobble_pos
|
||||||
if wobble_way == "right":
|
wobbl = f"{wobr}🐄️{wobl}"
|
||||||
wobble_pos += 1
|
feld = change_block(feld," " * txhalb+"↓",[ty-3,0])
|
||||||
if wobble_site == "right":
|
feld = change_block(feld,f"[{wobbl}]",[ty-2,0])
|
||||||
points += 1
|
print(strfeld(feld))
|
||||||
|
if wobble_pos > txhalb:
|
||||||
|
wobble_site = "left"
|
||||||
else:
|
else:
|
||||||
points -= 1
|
wobble_site = "right"
|
||||||
else:
|
|
||||||
wobble_pos -= 1
|
|
||||||
if wobble_site == "right":
|
|
||||||
points -= 1
|
|
||||||
else:
|
|
||||||
points += 1
|
|
||||||
|
|
||||||
if wobble_pos >= tx - 4:
|
|
||||||
wobble_way = "left"
|
|
||||||
elif wobble_pos == 0:
|
|
||||||
wobble_way = "right"
|
|
||||||
|
|
||||||
sleep(wobble_speed)
|
if wobble_way == "right":
|
||||||
clear()
|
wobble_pos += 1
|
||||||
|
if wobble_site == "right":
|
||||||
if running == "finito":
|
points += 1
|
||||||
exit()
|
else:
|
||||||
|
points -= 1
|
||||||
#tx halb = max points #in ausgerechneten bruch und an in bruch mit nenner 100 ergibt zähler mit punktewert
|
else:
|
||||||
|
wobble_pos -= 1
|
||||||
for a in range(int(points*2)):
|
if wobble_site == "right":
|
||||||
print("-" * a + "🐄️", end="\r")
|
points -= 1
|
||||||
sleep(0.01)
|
else:
|
||||||
|
points += 1
|
||||||
points = int((points/txhalb)*100)
|
|
||||||
print("\n", points, "%")
|
if wobble_pos >= tx - 5:
|
||||||
|
wobble_way = "left"
|
||||||
feld = genfeld()
|
elif wobble_pos == 0:
|
||||||
# Randomly choose a cow
|
wobble_way = "right"
|
||||||
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
|
|
||||||
cowlistlength = len(cows)
|
sleep(wobble_speed)
|
||||||
cow = cows[random.randint(0, cowlistlength - 1)]
|
clear()
|
||||||
# Needed: find our screensize. We are in textmode here
|
|
||||||
#termsize_xy = os.get_terminal_size()
|
if key_space == True:
|
||||||
### I m p o r t a n t p a r a m e t e r s ###
|
break
|
||||||
# X-Resolution of the display
|
points_prozent = int((points/txhalb)*100)
|
||||||
xmax = tx-1 #termsize_xy[0] - 1
|
for a in range(int(points*2)):
|
||||||
xsteps = 20#xmax
|
feld = change_block(feld,"-"*a+"🐄️",[0,0])
|
||||||
ymax = ty #termsize_xy[1]
|
feld = change_block(feld,str(points_prozent)+"%",[1,int(tx/2-2)])
|
||||||
ymin = 0
|
print(strfeld(feld))
|
||||||
xmin = 0
|
sleep(0.01)
|
||||||
startwinkel = 70
|
clear()
|
||||||
startgeschwindigkeit = 60
|
|
||||||
starthoehe = 0
|
|
||||||
schlafzeit = 0.05
|
|
||||||
###
|
|
||||||
# needed for erasing old position
|
|
||||||
xold = xmin
|
|
||||||
yold = ymin
|
|
||||||
x = xmin
|
|
||||||
y = xmin
|
|
||||||
# Call the function, which calculates the coordinates)
|
|
||||||
ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=1, xstep=2)
|
|
||||||
|
|
||||||
feld = bg_char(feld,"-")
|
|
||||||
|
|
||||||
# here we draw the cow
|
|
||||||
for count in range(xmin, len(ergebnis), 2):
|
|
||||||
xold, yold = x, y
|
|
||||||
x, y = ergebnis[count], ergebnis[count + 1]
|
|
||||||
change_block(feld,"@",[x, y])
|
|
||||||
sleep(schlafzeit)
|
|
||||||
change_block(feld,"#",[xold, yold]) #☁️
|
|
||||||
print(strfeld(feld))
|
print(strfeld(feld))
|
||||||
print()
|
|
||||||
sleep(2)
|
|
||||||
#sys.exit(home + curon)
|
## Randomly choose a cow
|
||||||
|
#cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
|
||||||
|
#cowlistlength = len(cows)
|
||||||
|
#cow = cows[random.randint(0, cowlistlength - 1)]
|
||||||
|
## Needed: find our screensize. We are in textmode here
|
||||||
|
##termsize_xy = os.get_terminal_size()
|
||||||
|
#### I m p o r t a n t p a r a m e t e r s ###
|
||||||
|
## X-Resolution of the display
|
||||||
|
#xmax = tx-1 #termsize_xy[0] - 1
|
||||||
|
#xsteps = 20#xmax
|
||||||
|
#ymax = ty #termsize_xy[1]
|
||||||
|
#ymin = 0
|
||||||
|
#xmin = 0
|
||||||
|
#startwinkel = 70
|
||||||
|
#startgeschwindigkeit = 60
|
||||||
|
#starthoehe = 0
|
||||||
|
#schlafzeit = 0.05
|
||||||
|
####
|
||||||
|
## needed for erasing old position
|
||||||
|
#xold = xmin
|
||||||
|
#yold = ymin
|
||||||
|
#x = xmin
|
||||||
|
#y = xmin
|
||||||
|
## Call the function, which calculates the coordinates)
|
||||||
|
#ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=1, xstep=2)
|
||||||
|
#
|
||||||
|
#feld = bg_char(feld,"-")
|
||||||
|
#
|
||||||
|
## here we draw the cow
|
||||||
|
#for count in range(xmin, len(ergebnis), 2):
|
||||||
|
# xold, yold = x, y
|
||||||
|
# x, y = ergebnis[count], ergebnis[count + 1]
|
||||||
|
# change_block(feld,"@",[x, y])
|
||||||
|
# sleep(schlafzeit)
|
||||||
|
# change_block(feld,"#",[xold, yold]) #☁️
|
||||||
|
# print(strfeld(feld))
|
||||||
|
# print()
|
||||||
|
#sleep(2)
|
||||||
|
##sys.exit(home + curon)
|
Loading…
Reference in a new issue