Funktioniert, mit Meispiel
This commit is contained in:
parent
eb7f4b64aa
commit
2d1c8f7d19
1 changed files with 46 additions and 15 deletions
|
@ -6,7 +6,7 @@ import os, sys, termios, tty, time, random
|
||||||
from math import sin, cos, tan, sqrt
|
from math import sin, cos, tan, sqrt
|
||||||
from time import sleep
|
from time import sleep
|
||||||
|
|
||||||
|
######################################################
|
||||||
def berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe):
|
def berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe):
|
||||||
x = 0
|
x = 0
|
||||||
y = x**2
|
y = x**2
|
||||||
|
@ -17,6 +17,7 @@ def berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigk
|
||||||
jupiter = 24
|
jupiter = 24
|
||||||
gravitation = erde
|
gravitation = erde
|
||||||
startwinkel = startwinkel * deg2rad
|
startwinkel = startwinkel * deg2rad
|
||||||
|
cowlength = len(cow) + 1
|
||||||
|
|
||||||
# Calculate time of flight
|
# Calculate time of flight
|
||||||
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
|
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
|
||||||
|
@ -38,33 +39,63 @@ def berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigk
|
||||||
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)
|
||||||
|
|
||||||
# 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:
|
||||||
# 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 * 100 + 50) / 100)]
|
||||||
else:
|
else:
|
||||||
scala += [x, 0]
|
scala += [0, 0]
|
||||||
|
|
||||||
xold = x
|
xold = x
|
||||||
|
|
||||||
return scala
|
return scala
|
||||||
|
|
||||||
|
|
||||||
|
######################################################
|
||||||
# berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe):
|
# berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe):
|
||||||
|
|
||||||
|
# set position of cursor
|
||||||
|
def curpos(x, y):
|
||||||
|
print("\033[%d;%dH" % (ymax - y, x), end="", flush=True)
|
||||||
|
|
||||||
cow = "🦝"
|
|
||||||
cowlength = len(cow)
|
# Randomly choose a cow
|
||||||
xmax = 157
|
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️ 🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
|
||||||
ymax = 38
|
cowlistlength = len(cows)
|
||||||
ymin = 0
|
cow = cows[random.randint(0, cowlistlength - 1)]
|
||||||
xmin = 0
|
|
||||||
xold = xmin
|
|
||||||
# pi is not defined by default
|
# pi is not defined by default
|
||||||
pi = 3.1416
|
pi = 3.1416
|
||||||
deg2rad = pi / 180
|
deg2rad = pi / 180
|
||||||
|
|
||||||
|
# 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 = termsize_xy[0] - 1
|
||||||
xsteps = xmax
|
xsteps = xmax
|
||||||
wurfweite = 0
|
ymax = termsize_xy[1]
|
||||||
startwinkel = 34
|
ymin = 0
|
||||||
startgeschwindigkeit = 23
|
xmin = 0
|
||||||
|
startwinkel = 34
|
||||||
|
startgeschwindigkeit = 31
|
||||||
starthoehe = 0
|
starthoehe = 0
|
||||||
print(berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe))
|
###
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
|
||||||
|
# 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)
|
||||||
|
print(cow, end="")
|
||||||
|
curpos(xold, yold)
|
||||||
|
bla = input("CR please...")
|
||||||
|
|
Loading…
Reference in a new issue