Made it usable as module.

This commit is contained in:
The Wobbler 2023-12-29 18:54:39 +01:00
parent d085bd72af
commit b8369e0bf8

View file

@ -56,47 +56,50 @@ def berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigk
# some useful control
clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h"
# set position of cursor
def curpos(x, y):
print("\033[%d;%dH" % (ymax - y, x), end="", flush=True)
# Randomly choose a cow
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
cowlistlength = len(cows)
cow = cows[random.randint(0, cowlistlength - 1)]
# pi is not defined by default
pi = 3.1416
deg2rad = pi / 180
if __name__ == "__main__":
# Randomly choose a cow
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
cowlistlength = len(cows)
cow = cows[random.randint(0, cowlistlength - 1)]
# pi is not defined by default
pi = 3.1416
deg2rad = pi / 180
# Needed: find our screensize. We are in textmode here
termsize_xy = os.get_terminal_size()
# 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 ###
### 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 = termsize_xy[0] - 1
xsteps = xmax
ymax = termsize_xy[1]
ymin = 0
xmin = 0
startwinkel = 34
startgeschwindigkeit = 31
starthoehe = 0
schlafzeit = 0.05
###
# X-Resolution of the display
xmax = termsize_xy[0] - 1
xsteps = xmax
ymax = termsize_xy[1]
ymin = 0
xmin = 0
startwinkel = 34
startgeschwindigkeit = 31
starthoehe = 0
schlafzeit = 0.05
###
# needed for erasing ol position
xold = xmin
yold = ymin
x = xmin
y = xmin
# needed for erasing ol position
xold = xmin
yold = ymin
x = xmin
y = xmin
# Call the function, which calculates the coordinates)
ergebnis = berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe)
print(curoff)
# here we draw the cow
for count in range(xmin, len(ergebnis), 2):
# Call the function, which calculates the coordinates)
ergebnis = berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe)
print(curoff)
# here we draw the cow
for count in range(xmin, len(ergebnis), 2):
xold, yold = x, y
x, y = ergebnis[count], ergebnis[count + 1]
curpos(x, y)
@ -106,4 +109,4 @@ for count in range(xmin, len(ergebnis), 2):
print("☁️ ", end="")
sys.exit(home + cow + curon)
sys.exit(home + cow + curon)