mehr kleinigkeiten korrigiert
This commit is contained in:
parent
63d7fa486f
commit
cbd60f372d
1 changed files with 25 additions and 15 deletions
|
@ -18,6 +18,7 @@ xmax = termsize_xy[0] - 1
|
||||||
ymax = termsize_xy[1]
|
ymax = termsize_xy[1]
|
||||||
ymin = 0
|
ymin = 0
|
||||||
xmin = 0
|
xmin = 0
|
||||||
|
xold = xmin
|
||||||
|
|
||||||
# pi is not defined by default
|
# pi is not defined by default
|
||||||
pi = 3.1416
|
pi = 3.1416
|
||||||
|
@ -28,6 +29,8 @@ def curpos(x, y):
|
||||||
print("\033[%d;%dH" % (ymax - y, x), end="", flush=True)
|
print("\033[%d;%dH" % (ymax - y, x), end="", flush=True)
|
||||||
|
|
||||||
|
|
||||||
|
outputfile = open("cowyeetflugbahn.txt", "w")
|
||||||
|
|
||||||
# CTRL and ESC-codes for the used outputdevice. Probably a terminal.
|
# CTRL and ESC-codes for the used outputdevice. Probably a terminal.
|
||||||
clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h"
|
clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h"
|
||||||
|
|
||||||
|
@ -46,10 +49,12 @@ scala = []
|
||||||
|
|
||||||
# used, if input is disabled
|
# used, if input is disabled
|
||||||
starthoehe = 0
|
starthoehe = 0
|
||||||
startwinkel = 26
|
startwinkel = 26 * deg2rad
|
||||||
startgeschwindigkeit = 23
|
startgeschwindigkeit = 36
|
||||||
loeschen = "n"
|
loeschen = "y"
|
||||||
|
|
||||||
|
bla = input("Parameter editieren (y) oder Vorgabe nutzen?")
|
||||||
|
if bla == "y":
|
||||||
# Be a friendly host, lets have a talk.
|
# Be a friendly host, lets have a talk.
|
||||||
# comment out to speed up testing
|
# comment out to speed up testing
|
||||||
starthoehe = float(input("Starthöhe in Metern, empf: 0-20: "))
|
starthoehe = float(input("Starthöhe in Metern, empf: 0-20: "))
|
||||||
|
@ -60,7 +65,7 @@ loeschen = input("Kuh löschen? (y/n)")
|
||||||
|
|
||||||
# Calculate time of flight
|
# Calculate time of flight
|
||||||
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
|
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
|
||||||
|
schlafdauer = flugdauer / xmax
|
||||||
# Calculate maximum height
|
# Calculate maximum height
|
||||||
hoehe = 0.5 * gravitation * flugdauer**2 + starthoehe
|
hoehe = 0.5 * gravitation * flugdauer**2 + starthoehe
|
||||||
|
|
||||||
|
@ -88,6 +93,8 @@ print(
|
||||||
starthoehe,
|
starthoehe,
|
||||||
"\nhoehe: ",
|
"\nhoehe: ",
|
||||||
hoehe,
|
hoehe,
|
||||||
|
"\nschlafdauer: ",
|
||||||
|
schlafdauer,
|
||||||
)
|
)
|
||||||
|
|
||||||
bla = input("CR please:")
|
bla = input("CR please:")
|
||||||
|
@ -96,23 +103,26 @@ bla = input("CR please:")
|
||||||
curpos(1, ymax)
|
curpos(1, ymax)
|
||||||
|
|
||||||
# cowlength is 2, if cow is an UTF8-Icon, otherwise 1
|
# cowlength is 2, if cow is an UTF8-Icon, otherwise 1
|
||||||
for x in range(1, xsteps, cowlength):
|
for x in range(xmin, xsteps - 1, cowlength):
|
||||||
# the formula, which generates the y position for the corresponding x, shamelessly ripped from some schoolbook and modified.
|
# the formula, which generates the y position for the corresponding x, shamelessly ripped from some schoolbook and modified.
|
||||||
yold = y
|
yold = y
|
||||||
y = (-(gravitation / (2 * startgeschwindigkeit**2 * cos(startwinkel) ** 2)) * x**2) + (tan(startwinkel) * x + starthoehe)
|
y = (-(gravitation / (2 * startgeschwindigkeit**2 * cos(startwinkel) ** 2)) * x**2) + (tan(startwinkel) * x + starthoehe)
|
||||||
|
|
||||||
|
time.sleep(schlafdauer)
|
||||||
# Ensure, that nothing has to be drawn outside the viewport
|
# Ensure, that nothing has to be drawn outside the viewport
|
||||||
if y < ymax and y > ymin:
|
if y < ymax and y > ymin:
|
||||||
curpos(x, y)
|
curpos(x, y)
|
||||||
print(cow, end="")
|
print(cow, end="")
|
||||||
# Stash awa the coordinates into scala, which will be returned
|
# Stash awa the coordinates into scala, which will be returned
|
||||||
scala += [x, int(y * 10 + 5) / 10]
|
scala += [x, int(y * 10 + 5) / 10]
|
||||||
time.sleep(0.03)
|
|
||||||
if loeschen == "y":
|
if loeschen == "y":
|
||||||
curpos(x - 2, yold)
|
curpos(xold, yold)
|
||||||
print(" ", end="")
|
print(" ", end="")
|
||||||
|
else:
|
||||||
|
scala += [x, 0]
|
||||||
|
|
||||||
|
xold = x
|
||||||
|
|
||||||
curpos(0, 0)
|
curpos(0, 0)
|
||||||
# print(scala)
|
outputfile.write(str(scala))
|
||||||
sys.exit(curon + "Moooooooooooo.")
|
sys.exit(curon + "Moooooooooooo.")
|
||||||
|
|
Loading…
Reference in a new issue