From d4aa1c12bb3286c784bc065741db884d279028f0 Mon Sep 17 00:00:00 2001 From: megamichi Date: Sat, 13 Jan 2024 19:55:47 +0100 Subject: [PATCH] great update # aber komme mit wuffels parrable funktion nicht klar --- __pycache__/tengine.cpython-311.pyc | Bin 0 -> 3669 bytes .../__pycache__/parabelfunc.cpython-311.pyc | Bin 0 -> 3754 bytes physics/kreis.py | 61 +++++++++ physics/parabelfunc.py | 128 ++++++++++++++++++ physics/parabeltest.py | 128 ++++++++++++++++++ tengine/README.md | 2 + tengine/__pycache__/main.cpython-311.pyc | Bin 0 -> 3674 bytes tengine/__pycache__/tengine.cpython-311.pyc | Bin 0 -> 3692 bytes tengine/main.py | 50 +++++++ tengine/test.py | 14 ++ terminal engine/README.md | 0 .../__pycache__/tengine.cpython-311.pyc | Bin 2501 -> 0 bytes terminal engine/tengine.py | 42 ------ terminal engine/test.py | 11 -- v1.py | 52 ++++--- v2.py | 128 ++++++++++++++++++ 16 files changed, 542 insertions(+), 74 deletions(-) create mode 100644 __pycache__/tengine.cpython-311.pyc create mode 100644 physics/__pycache__/parabelfunc.cpython-311.pyc create mode 100644 physics/kreis.py create mode 100644 physics/parabelfunc.py create mode 100644 physics/parabeltest.py create mode 100644 tengine/README.md create mode 100644 tengine/__pycache__/main.cpython-311.pyc create mode 100644 tengine/__pycache__/tengine.cpython-311.pyc create mode 100644 tengine/main.py create mode 100644 tengine/test.py delete mode 100644 terminal engine/README.md delete mode 100644 terminal engine/__pycache__/tengine.cpython-311.pyc delete mode 100644 terminal engine/tengine.py delete mode 100644 terminal engine/test.py create mode 100644 v2.py diff --git a/__pycache__/tengine.cpython-311.pyc b/__pycache__/tengine.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..f9f00add3d0dda81fde5301e8d159f6403670d94 GIT binary patch literal 3669 zcmb_eZ)h9I6`$EZl59zKl)L1l*vZNNnyS4zP3*?@)%fDn)R&Yqq-klJvoW%EBX2BA zzS&KEHfvBJl+B^Ga?xQGTo5HqZ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?SbeziZc0|AH%Mh5rIOMtj`uA7ZoWfES}@QCexB%s?~8v!d4czol6cByXQ0o} z%^ALhfQzxs4lfm$qB0%`Y^vGx-ia&~R#(SZzlpj+BNv4Gf8kTM=6~(#%+dcw)=znqn;5fn`<8 zE*o~oT`iY$;`A5@FwCVoK9P8oapO$z*P6;y2u#;tWEiI`0^v7QzWQ*Xw1CftY3fk^ ziYVXT?ydCVqXF4S;q5SX&5af{+KBZvBmK3By<3kapY=5cMjDaPdSnzI6w~zhMKQ;4 zGjNk!%oK9>SMzYL9K4J5V+8VdB7ghvWXdq$FpQ8qHgKr%)0_w( zN1@5pf^t8nPO%x7jJZ$$3JC0r(&r>u_t%3^q8>^#LOo5a1NEV+P#Z(zO{`NzxhNE` z97>cL+pk@_ubR==}#X CUgVkp literal 0 HcmV?d00001 diff --git a/physics/__pycache__/parabelfunc.cpython-311.pyc b/physics/__pycache__/parabelfunc.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..833948268b8addec6ba5962b71c0b414463d5fd7 GIT binary patch literal 3754 zcmahLYi}FJaqoB}kK|D#Wj!n^vL*Q;(GM9>+@yBYIEpPpezvyd#6HVlY3_=o#D}tX zj4g(;H8ot?W+{C+Qj*7?_8lP{YP`a5G9&7J|~;cs|^ZXt{?mqv1ZT)7EMd>M0K8vr zk^^!OyW|k|%FWm(ufx(cB)5=O?4JVP2$eV*z)f-+k4QUdTjUVB15j`Bdcx%VWJg1S z5m}Gj1&DtUR^PELu(`(yNDjjaG}+l$u?WPS27~11$a8p=cHNfTMY?dH;Dm@bz`T2v zwT&3b-2go}DEH!!yb0*dxLMvpdgQI7TkeCgA0Pr=CDKJUk`1JnY$BUU2nX)2TNJ@N zK)uP^Kx;b*tlcGtK)QqU0B$GS*3RL;q5~`d)Y}1c{*1hn^pi-Om$!oVZDi+@Xc-4P z0@Wun(CfFOYhkO_o|^4>I|<{KyRFZd@sKTRqp|f{$X3$#4DIc>?OAr_&cePtu#Yu2 zYg^(b2O9e#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^eupQ z0Dc4jveIt>?!eqU0N5)10md@GM?izkn>YS-|7YF6gRR9M16&6=^9MFdH(-1p;5`85 z@Am*Ozj%{M5a3ELLqmWbUDxe>a6Vz+Df>U8{eU7Ijlhs+AGE)fuQFc|r(Ho;A@=>T zD`;ew#j`KJGNV{7sFOICv4l)aO|B}U?EdSOR8UhHLYZZYpH9&Ln_#8Ga>mmnMlB(k z%Mkl!auX9E%u^_cu0)hjOu%do?$|wlHwz2Wf&HUgv_gqh1um+j3Q&Goy<=4L(hO~8;kfJ?tk?-eSw7QthFTeFV~G9E zK?#p1)3J#{y|m}j7)m?fC;4WH1PbegY)YZq*(z2cVOP041S613DfKq8)5uQ9uf(BD z4(HS46?zQx*dtLgkgzoe$8j|;;@S<=_RYPDHXGm8t6wt$6~!fKeAO%I%JqKDT@!b4 zp&D9?(j3}wk~2|Qb84#odg(M&7H^a0s=B?J083$+i{rjmLywV&1W7Oa#nE9pI%)!v zCVA~ZwWYnZzbyRx&@T^Z$Ew~Y{j&bn+~sm?q3d4A>=`rzFI1p=cWe70sC9j%-b(XU zv$?<0+z%fOFOu3zZ_d3^9yWblV9OsW4PQT_9jyA=m>48JsezhXv?JBdE<;#f4K-_r zt5CNOv&tD{3IRZ(#6D1fU?0J5Bd~EnSinmM?;SCQPaAK0VvX zaW&9hcFtW{5SLo-g>H9Lx?cb(r$1j6n{=1{W~t}8G$-j&RrKplJzk=Q7&gUlMGON` z7fzaDM@8%~#E$wJwKVpWMyh<$5W7vWyCQZ20e#sHx##NWwNY&pw(0b1`>&1aW2KSn W= xmax: + x = xmax + + if y >= ymax: + y = ymax + + elif y <= ymin: + y = ymin + + # Stash away the coordinates into scala, which will be returned + scala += [x, int((y * 100 + 50) / 100)] + + if y == ymin and not first_run: + break + + first_run = False + + return scala + + +############################################################################################# +# berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe): + +# some useful control +clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h" + + +g_erde = 9.81 # gravitation examples +mond = 1.6 +jupiter = 24 + +# set position of cursor +def curpos(x, y): + print("\033[%d;%dH" % (ymax - y, x), end="", flush=True) + + +if __name__ == "__main__": + # Randomly choose a cow + cows = "πŸ΅πŸ’πŸ¦πŸ¦§πŸ•πŸ―πŸ¦πŸ©πŸ…πŸ΄πŸŽπŸ¦„πŸ¦ŒπŸ—πŸ‚πŸƒπŸ„πŸͺπŸ«πŸ¦™πŸ¦’πŸΉπŸ¦˜πŸ¦‘πŸ§πŸ•ŠοΈ πŸ¦…πŸ¦†πŸ¦‰πŸπŸ¦ŽπŸŠπŸ¦œπŸ¦šπŸ¦©πŸ²πŸ‰πŸ¦•" + cowlistlength = len(cows) + cow = cows[random.randint(0, cowlistlength - 1)] + + + # 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 * 2 + ymax = termsize_xy[1] + ymin = 0 + xmin = 0 + startwinkel = 34 + startgeschwindigkeit = 60 + starthoehe = 0 + schlafzeit = 0.05 + ### + + # needed for erasing old position + xold = xmin + yold = ymin + x = xmin + y = xmin + + # Call the function, which calculates the coordinates) + ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=g_erde, xstep=2) + 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) + print(cow, end="") + sleep(schlafzeit) + curpos(xold, yold) + print("☁️ ", end="") + + sleep(2) + + + sys.exit(home + curon) diff --git a/physics/parabeltest.py b/physics/parabeltest.py new file mode 100644 index 0000000..1f89ad3 --- /dev/null +++ b/physics/parabeltest.py @@ -0,0 +1,128 @@ +#!/usr/bin/python3 +# -*- coding: utf-8 -*- + + +import os, sys, termios, tty, time, random +from math import sin, cos, tan, sqrt +from time import sleep + +# Randomly choose a cow +cows = "πŸ΅πŸ’πŸ¦πŸ¦§πŸ•πŸ―πŸ¦πŸ©πŸ…πŸ΄πŸŽπŸ¦„πŸ¦ŒπŸ—πŸ‚πŸƒπŸ„πŸͺπŸ«πŸ¦™πŸ¦’πŸΉπŸ¦˜πŸ¦‘πŸ§πŸ•ŠοΈπŸ¦…πŸ¦†πŸ¦‰πŸπŸ¦ŽπŸŠπŸ¦œπŸ¦šπŸ¦©πŸ²πŸ‰πŸ¦•" +cowlistlength = len(cows) +cow = cows[random.randint(0, cowlistlength - 1)] +cowlength = len(cow) + +# Needed: find our screensize +termsize_xy = os.get_terminal_size() +xmax = termsize_xy[0] - 1 +ymax = termsize_xy[1] +ymin = 0 +xmin = 0 +xold = xmin + +# pi is not defined by default +pi = 3.1416 +deg2rad = pi / 180 + +# position cursor at x,y - where x=0 y=0 is the left lower corner like in mathematical diagrams +def curpos(x, y): + 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. +clear, home, curoff, curon = "'\x1b[2J\x1b[H", "\x1b[H", "\x1b[?25l", "\x1b[?25h" + + +# some scales, we need +# not everything has to be recomputed in loops. +xsteps = xmax +x = 0 +y = x**2 +erde = 9.81 +mond = 1.6 +jupiter = 24 +gravitation = erde +# in scala the resulting coordinates will be returned +scala = [] + +# used, if input is disabled +starthoehe = 0 +startwinkel = 26 * deg2rad +startgeschwindigkeit = 36 +loeschen = "y" + +bla = input("Parameter editieren (y) oder Vorgabe nutzen?") +if bla == "y": + # Be a friendly host, lets have a talk. + # comment out to speed up testing + starthoehe = float(input("StarthΓΆhe in Metern, empf: 0-20: ")) + 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 +flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation +schlafdauer = flugdauer / xmax +# Calculate maximum height +hoehe = 0.5 * gravitation * flugdauer**2 + starthoehe + +# calculate length of flight +wurfweite = ( + startgeschwindigkeit + * cos(startwinkel) + * (startgeschwindigkeit * sin(startwinkel) + sqrt(startgeschwindigkeit**2 * sin(startwinkel) ** 2 + 2 * gravitation * starthoehe)) +) / gravitation + + +# init screen and wait for userinput + +print(clear, curoff) +print( + "xteps: ", + xsteps, + "\nwurfweite: ", + wurfweite, + "\nstartwinkel: ", + startwinkel / deg2rad, + "\nstartgeschwindigkeit: ", + startgeschwindigkeit, + "\nstarthoehe: ", + starthoehe, + "\nhoehe: ", + hoehe, + "\nschlafdauer: ", + schlafdauer, +) + +bla = input("CR please:") + +# position cursor down left corner +curpos(1, ymax) + +# cowlength is 2, if cow is an UTF8-Icon, otherwise 1 +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. + yold = y + 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 + if y < ymax and y > ymin: + curpos(x, y) + print(cow, end="") + # Stash awa the coordinates into scala, which will be returned + scala += [x, int(y * 10 + 5) / 10] + if loeschen == "y": + curpos(xold, yold) + print(" ", end="") + else: + scala += [x, 0] + + xold = x + +curpos(0, 0) +outputfile.write(str(scala)) +sys.exit(curon + "Moooooooooooo.") diff --git a/tengine/README.md b/tengine/README.md new file mode 100644 index 0000000..c2286cf --- /dev/null +++ b/tengine/README.md @@ -0,0 +1,2 @@ +# A little Text Engine for Cowyeet + diff --git a/tengine/__pycache__/main.cpython-311.pyc b/tengine/__pycache__/main.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..cd0285d7e0f4eef6dd93269cb6a4521d1384813a GIT binary patch literal 3674 zcmb_eZ)h9I6`$EZl59zKl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jC6xDb#m$GR8PhWC1_%`~`57!zWp~f>*=_fdRP%A5y7cD`M+Lni-1_Pi%QzQ;cOh zu&ip?Wy9{cr{!`^oE`%KhPhP7ClZe`Zk!4JT2q+{f$18I4C9nVApC~PS062u7V!Bn zO&!W#5#@kBs7jVwxVm zDCQV$299&ZX+FfJ%N7bcLsztenL_TtY97v&gU7Lcj6nWQG56{J00R4>^aV-Q{q-P}sD~1bP)`%B7q=|`bpfsyk8p+ GdjA33sOF#m literal 0 HcmV?d00001 diff --git a/tengine/__pycache__/tengine.cpython-311.pyc b/tengine/__pycache__/tengine.cpython-311.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0b6946ca6da347168dd6213c8debd4a9fa0eead0 GIT binary patch literal 3692 zcmb_eO>7&-6`t82k`hVDbYh#dWQY2z%Qls3OSPm_P%J};V;2?RxJ6q>f|U-f#znf5Tq2jF`PzLz(FY?CZ8$$WB?D&&7vu_cuHKn?Y2!Oe3m zCy%s9s0C)rx5*woq{%(9C)mR9k8Qf3A9haWG~LJ)R#vArzL!<= zch#ISJeezG(m8z!I_{vSi$>DpK#HUu8FXs-mUX-R^Ag6uw6@IB`K)RS#-|LC*g6M` zLZ5X3+35K%3b~da!7R`c9(U?)%+c|ep}z@#PVJ=NuMrt+!Y14qtQ#a!0y_Z>C|+kB z(BVw3)(*BbGPFN91<`wf6v;kc;P2``uI*`0HCV0@9&Z9q8h3<4Fe~E$76}4_gYXe_ zw*3G^eyf*^OrXTA9#JT3Qf2Reb+kCP0^$#F@+-uQ=A0pQdeojBpm7t58xU{ z%&Ga5WJ`GAwv<^)Gn=Mux~NMqDG8-zu*K{G4zjbrMl0yQ0a7I2Mo)e*QZ}|GDie+9 zxn}g-0TJZ$oLKbR*y%6y>S&GbjBS|}vk@C?#s&`v?SKhDtm*y4IcugID_t*7KfGz( zJP?8VJltLU8Mn62S#Uet&{v^@-d=3s5Dglm3{cD2D#?irTa9dltSJ3ic;4nLO z*SL0YLxrTF=5@3NSlRXQNXyQS6vo`Q;nN=g0YjgNS7ViMb$TmWU8;Suvs~}~LGeT2 z7H{mo6+a-dJjRI?+z+2DE1$h@y}zI6uU*>d-KC90YIpqE^wXc#<73th>&A0uptk-j z_Q-seZd@3v$H%Q3`xmc3G)Po0ReGC|^VRj;*pAtVyjzdF3y5`N0&J#T+NeZO_=B%P z72&D)7;fqbzb%xZ9EmAuc0=gNu=BtHe-+id0*$=Nw7hXVO++#|HO&_E3{%xSy95%5 zI=u%7gg&Xmx=?0y>1;zf+my~i$Eh54hxCWOM1gsXBd-fQz`s|+<7wZSDB^%e`suL{ zuTaE}%3QMmoIJ4LUi1fp!{}IS* z6Bd;(LOzl&T6BM4xE>m|B@JDUL>TBz^pWDIql00Zvg`3vAEhflI}8Lx;90s~SEzNb>bR^Zl+G&2?; ztl09JrWi|hU`f@oONQNXSIgy`a6JYB3{$F(FC`vq+;9{8t)?;+;?q?a8OA9KK==)n zuRNSD&EqR#nmUv}Cd&7>dMmy7c0e{#ctVU_b%REYHe!9vNPlf&_tvAyXMK%+ z9vQ`V#WX#7Sj;lq3>@dO)4YdGmn{@@hOTG_Glks!l{}m)2hU{v2!Z^$$e%zwr!tH? z3B7q=| O`bpfsyk8p+djA3TAnmgN literal 0 HcmV?d00001 diff --git a/tengine/main.py b/tengine/main.py new file mode 100644 index 0000000..c3218a6 --- /dev/null +++ b/tengine/main.py @@ -0,0 +1,50 @@ +#!/bin/python3 +from os import get_terminal_size +tx,ty = get_terminal_size().columns ,get_terminal_size().lines + +def genfeld(): + return [[' ' for _ in range(tx)] for _ in range(ty)] + +def bg_char(feld, char=' '): + for a in range(len(feld)): + for b in range(len(feld[0])): + feld[a][b] = char + return feld + +def strfeld(feld): + return '\n'.join([''.join(row) for row in feld]) + +def change_char(feld, character, position): + feld[position[0]][position[1]] = character + +def change_block(feld, block, position): + position = [position[0]+1,position[1]] + pposition = position + for zeichen in block: + if zeichen == '\n': + pposition = [pposition[0] + 1, position[1]] + else: + pposition = [pposition[0], pposition[1] + 1] + feld[pposition[0]][pposition[1]] = zeichen + return feld + +def clear(): + print('\033c', end='') + +def draw_border(feld, border_char='+'): + for i in range(len(feld)): + feld[i][0] = feld[i][-1] = border_char + for j in range(len(feld[0])): + feld[0][j] = feld[-1][j] = border_char + global tx,ty + tx -= 2;ty -= 2 + return feld + +#def move_cursor(x, y): +# print(f'\033[{y};{x}H', end='') + +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 + return feld diff --git a/tengine/test.py b/tengine/test.py new file mode 100644 index 0000000..f3003f9 --- /dev/null +++ b/tengine/test.py @@ -0,0 +1,14 @@ +import forgejo.cowyeet_terminal.tengine.main as main +feld = main.genfeld() + +block = "halli\nhallo\nfurz" +block2 = """halli +hallouuuuuuuuuuuuu +furz""" + +feld = main.bg_char(feld,"#") +#feld = tengine.draw_border(feld) +feld = main.change_block(feld,block2,[2,2]) +#feld = tengine.viereck(feld,[1,1],4,4,"-") +print(main.strfeld(feld)) +#tengine.clear_screen() \ No newline at end of file diff --git a/terminal engine/README.md b/terminal engine/README.md deleted file mode 100644 index e69de29..0000000 diff --git a/terminal engine/__pycache__/tengine.cpython-311.pyc b/terminal engine/__pycache__/tengine.cpython-311.pyc deleted file mode 100644 index 501f4dd4b7a2672e939c90a748e0788b73d63451..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2501 zcmbVN&1)M+6rY*h)rVJ#rPxmFI8Kz*2^FDMLQ@*IuED9A)=4ph99mq0k$2bf#`;GXD9hQZFp{Lvgz7(JO-bianrfH%3@%GKkn|bqo z@AqbZjYj(jTBL;mAy{~**a?iIW^U^+#KCu|W;R|4Rf(%TH10-E9zz;n_4RJtZ}ah%^x2bT~MZc zOcO>SYZeS>i|@qhql3PwoN1M`Vt#dc?PAs_EEzd{Vk%eEGC6A+6o0TwMWC!<5EZf; z8E-wc+s>WC#y*Szyq>}{g{_3#nL+LwKVkw^J?_i9;s z|6HAp_zV5lI{jtYW;U^<&J0_gg4s6gt{SU;(q=x#Kzy8}oKZ+B92x1!+H!__a>=kt z9?f`k(L#h0c(u`6%r2k}KL!0Ecr612q8F*8-$su={k`u_lp}VIds) zHh$ufQ@kV^SNmv*RKsYn*$e5F^#j9V}W;SlR11FudlWr_Mb}+9XZxo+&e%!FRAM*|Zy2Tk3^=4R~0l)ghbetgWB5Db%4f=aB>2 z2mFz&5>Lu)bQUw(3P6bU_1_NH(5;?ih~W0D;g%fke?b;xHtHL*4lCCZXX` zAt3Zf?D3b|bo0j6jg2{s+YLo(@gmds+oLSKh0P{9IfyTybHFoKv^XF))? z7bYrcXSjB*I@*wjYRlXAw^r)%`Caj}%BVXIa-{|WsaYQxCGFA47KwhfL6*XHw&d?poMqZw4jpC+A2HxhTg+KUWr$ANRR&g@$`>?G^*U_&0fFP34RFgPbwVFM|mZ-1-efQ=*i*B(dB3>?tR9l@oPkxPeci!rY#YGZofk tjK<)Y@ txhalb: + wobble_site = "left" + else: + wobble_site = "right" if wobble_way == "right": wobble_pos += 1 + if wobble_site == "right": + points += 1 + else: + points -= 1 else: wobble_pos -= 1 + if wobble_site == "right": + points -= 1 + else: + points += 1 - if wobble_pos >= tx - 1: + if wobble_pos >= tx - 4: wobble_way = "left" elif wobble_pos == 0: wobble_way = "right" - + sleep(wobble_speed) clear() if running == "finito": exit() -if wobble_pos > txhalb: - wobble_site = "left" -else: - wobble_site = "right" +#tx halb = max points #in ausgerechneten bruch und an in bruch mit nenner 100 ergibt zΓ€hler mit punktewert -if wobble_site == "right": - points = wobble_pos -else: - points = tx - wobble_pos - -point_quote = points - tx / 100 -for a in range(points * 2): +for a in range(int(points*2)): print("-" * a + "πŸ„οΈ", end="\r") sleep(0.01) -print("\n", point_quote, "%") + +points = int((points/txhalb)*100) +print("\n", points, "%") diff --git a/v2.py b/v2.py new file mode 100644 index 0000000..b4c4f1a --- /dev/null +++ b/v2.py @@ -0,0 +1,128 @@ +#!/usr/bin/python3 +import os +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 +import random + + +#def clear(): +# if os.name == "nt": +# os.system("cls") +# else: +# os.system("clear") + + +def on_press(key): + global running + if key == keyboard.Key.space: + running = False + + +def on_release(key): + global running + if key == keyboard.Key.esc: + # Stop listener + running = "finito" + + +listener = keyboard.Listener(on_press=on_press, on_release=on_release) + +listener.start() + +txhalb = int(tx / 2)-2 +wobble_speed = 0.01 +wobble_pos = 0 +wobble_way = "right" +points = 0 +running = True +while running == True: + wobl = "-" * (tx - wobble_pos - 5) + wobr = "-" * wobble_pos + wobbl = f"{wobr}πŸ„οΈ{wobl}" + print(" " * txhalb, "↓") + print(f"[{wobbl}]") + print(wobble_pos) + print(points) + print(tx) + print(txhalb) + + if wobble_pos > txhalb: + wobble_site = "left" + else: + wobble_site = "right" + + if wobble_way == "right": + wobble_pos += 1 + if wobble_site == "right": + points += 1 + else: + points -= 1 + else: + wobble_pos -= 1 + if wobble_site == "right": + points -= 1 + else: + points += 1 + + if wobble_pos >= tx - 4: + wobble_way = "left" + elif wobble_pos == 0: + wobble_way = "right" + + sleep(wobble_speed) + clear() + + if running == "finito": + exit() + +#tx halb = max points #in ausgerechneten bruch und an in bruch mit nenner 100 ergibt zΓ€hler mit punktewert + +for a in range(int(points*2)): + print("-" * a + "πŸ„οΈ", end="\r") + sleep(0.01) + +points = int((points/txhalb)*100) +print("\n", points, "%") + +feld = genfeld() +# Randomly choose a cow +cows = "πŸ΅πŸ’πŸ¦πŸ¦§πŸ•πŸ―πŸ¦πŸ©πŸ…πŸ΄πŸŽπŸ¦„πŸ¦ŒπŸ—πŸ‚πŸƒπŸ„πŸͺπŸ«πŸ¦™πŸ¦’πŸΉπŸ¦˜πŸ¦‘πŸ§πŸ•ŠοΈ πŸ¦…πŸ¦†πŸ¦‰πŸπŸ¦ŽπŸŠπŸ¦œπŸ¦šπŸ¦©πŸ²πŸ‰πŸ¦•" +cowlistlength = len(cows) +cow = cows[random.randint(0, cowlistlength - 1)] +# 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 = tx-1 #termsize_xy[0] - 1 +xsteps = 20#xmax +ymax = ty #termsize_xy[1] +ymin = 0 +xmin = 0 +startwinkel = 70 +startgeschwindigkeit = 60 +starthoehe = 0 +schlafzeit = 0.05 +### +# needed for erasing old position +xold = xmin +yold = ymin +x = xmin +y = xmin +# Call the function, which calculates the coordinates) +ergebnis = berechneflugbahn(xmax, ymax, xsteps, startwinkel, startgeschwindigkeit, starthoehe, gravitation=1, xstep=2) + +feld = bg_char(feld,"-") + +# here we draw the cow +for count in range(xmin, len(ergebnis), 2): + xold, yold = x, y + x, y = ergebnis[count], ergebnis[count + 1] + change_block(feld,"@",[x, y]) + sleep(schlafzeit) + change_block(feld,"#",[xold, yold]) #☁️ + print(strfeld(feld)) + print() +sleep(2) +#sys.exit(home + curon) \ No newline at end of file