problem mit engin
This commit is contained in:
parent
bb4fcf6530
commit
bc660afdbc
3 changed files with 36 additions and 20 deletions
Binary file not shown.
|
@ -1,9 +1,9 @@
|
|||
#!/bin/python3
|
||||
from os import get_terminal_size
|
||||
tx,ty = get_terminal_size().columns ,get_terminal_size().lines
|
||||
tx,ty = get_terminal_size().columns ,get_terminal_size().lines-2
|
||||
|
||||
def genfeld():
|
||||
return [[' ' for _ in range(tx)] for _ in range(ty)]
|
||||
return [[' ' for _ in range(tx)] for _ in range(ty+2)]
|
||||
|
||||
def bg_char(feld, char=' '):
|
||||
for a in range(len(feld)):
|
||||
|
@ -12,7 +12,9 @@ def bg_char(feld, char=' '):
|
|||
return feld
|
||||
|
||||
def strfeld(feld):
|
||||
return '\n'.join([''.join(row) for row in feld])
|
||||
return '\n'.join([''.join(row) for row in feld]).lstrip('\n').rstrip('\n')
|
||||
def prfeld(feld):
|
||||
print(strfeld(feld),end="\r")
|
||||
|
||||
def change_char(feld, character, position):
|
||||
feld[position[0]][position[1]] = character
|
||||
|
@ -46,5 +48,5 @@ def draw_border(feld, border_char='+'):
|
|||
def viereck(feld, start_pos, width, height, fill_char='#'):
|
||||
for i in range(height):
|
||||
for j in range(width):
|
||||
feld[start_pos[0] + i][start_pos[1] + j] = fill_char
|
||||
feld[start_pos[0]+1 + i][start_pos[1] + j] = fill_char
|
||||
return feld
|
||||
|
|
44
v2.py
44
v2.py
|
@ -3,9 +3,9 @@
|
|||
from tengine.main import *#ty,tx,clear,genfeld,strfeld,change_char,bg_char
|
||||
from pynput import keyboard
|
||||
from time import sleep
|
||||
from physics.parabelfunc import berechneflugbahn
|
||||
#from physics.parabelfunc import berechneflugbahn
|
||||
import ascii
|
||||
#import random
|
||||
import random
|
||||
|
||||
def on_press(key):
|
||||
global key_space
|
||||
|
@ -32,17 +32,25 @@ wobble_way = "right"
|
|||
points = 0
|
||||
startscreen = True
|
||||
running = True
|
||||
if not ty >= 11 :
|
||||
running = False
|
||||
print("please resize you teerminal over 11 lines")
|
||||
|
||||
if __name__ == "__main__" and running == True:
|
||||
feld = genfeld()
|
||||
feld = change_block(feld,ascii.logo,[1,int(tx/2-21)])
|
||||
feld = change_block(feld,ascii.logo,[0,int(tx/2-21)])
|
||||
|
||||
while startscreen == True:
|
||||
feld = change_block(feld,ascii.start_screen_text,[10,int(tx/2-5)])
|
||||
print(strfeld(feld))
|
||||
feld = change_block(feld,ascii.start_screen_text,[ty,int(tx/2-5)])
|
||||
prfeld(feld)
|
||||
sleep(0.2)
|
||||
feld = viereck(feld,[11,int(tx/2-4)],11,1," ")
|
||||
print(strfeld(feld))
|
||||
clear()
|
||||
if key_space == True:
|
||||
while not key_space == False:
|
||||
startscreen = False
|
||||
|
||||
feld = viereck(feld,[ty,int(tx/2-4)],11,1," ")
|
||||
prfeld(feld)
|
||||
sleep(0.2)
|
||||
clear()
|
||||
if key_space == True:
|
||||
|
@ -51,13 +59,18 @@ if __name__ == "__main__" and running == True:
|
|||
|
||||
feld = bg_char(feld," ")
|
||||
feld = change_block(feld,ascii.cowsay,[int(ty/2)-2,int (tx/2)-12])
|
||||
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
|
||||
cowlistlength = len(cows)
|
||||
cow = "#" cows[random.randint(0, cowlistlength - 1)]
|
||||
clear()
|
||||
#feld[ty][tx] ### 2zeichen kuhh mach probleme
|
||||
while running == True:
|
||||
wobl = "-" * (tx - wobble_pos - 5)
|
||||
wobr = "-" * wobble_pos
|
||||
wobbl = f"{wobr}🐄️{wobl}"
|
||||
feld = change_block(feld," " * txhalb+"↓",[ty-3,0])
|
||||
feld = change_block(feld,f"[{wobbl}]",[ty-2,0])
|
||||
print(strfeld(feld))
|
||||
wobbl = f"{wobr}{cow}{wobl}"
|
||||
feld = change_block(feld," " * txhalb+"↓",[ty-1,0])
|
||||
feld = change_block(feld,f"[{wobbl}]",[ty,0])
|
||||
prfeld(feld)
|
||||
if wobble_pos > txhalb:
|
||||
wobble_site = "left"
|
||||
else:
|
||||
|
@ -87,13 +100,14 @@ if __name__ == "__main__" and running == True:
|
|||
if key_space == True:
|
||||
break
|
||||
points_prozent = int((points/txhalb)*100)
|
||||
for a in range(int(points*2)-1):
|
||||
clear()
|
||||
for a in range(int(points*2)-2):
|
||||
feld = change_block(feld,"-"*a+"🐄️",[0,0])
|
||||
feld = change_block(feld,str(points_prozent)+"%",[1,int(tx/2-2)])
|
||||
print(strfeld(feld))
|
||||
prfeld(feld)
|
||||
sleep(0.01)
|
||||
clear()
|
||||
print(strfeld(feld))
|
||||
prfeld(feld)
|
||||
|
||||
|
||||
## Randomly choose a cow
|
||||
|
@ -131,7 +145,7 @@ if __name__ == "__main__" and running == True:
|
|||
# change_block(feld,"@",[x, y])
|
||||
# sleep(schlafzeit)
|
||||
# change_block(feld,"#",[xold, yold]) #☁️
|
||||
# print(strfeld(feld))
|
||||
# prfeld(feld)
|
||||
# print()
|
||||
#sleep(2)
|
||||
##sys.exit(home + curon)
|
Loading…
Reference in a new issue