mehr kleinigkeiten korrigiert

This commit is contained in:
Wolfgang Nowak 2023-11-14 16:04:03 +01:00
parent 63d7fa486f
commit cbd60f372d

View file

@ -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,21 +49,23 @@ 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"
# Be a friendly host, lets have a talk. bla = input("Parameter editieren (y) oder Vorgabe nutzen?")
# comment out to speed up testing if bla == "y":
starthoehe = float(input("Starthöhe in Metern, empf: 0-20: ")) # Be a friendly host, lets have a talk.
startwinkel = float(input("Startwinkel 0° - 90°: ")) * deg2rad # comment out to speed up testing
startgeschwindigkeit = float(input("Startgeschwindigkeit Meter (zb 20) pro Sekunde: ")) starthoehe = float(input("Starthöhe in Metern, empf: 0-20: "))
loeschen = input("Kuh löschen? (y/n)") startwinkel = float(input("Startwinkel 0° - 90°: ")) * deg2rad
startgeschwindigkeit = float(input("Startgeschwindigkeit Meter (zb 20) pro Sekunde: "))
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.")