Compare commits

..

No commits in common. "main" and "v1.0" have entirely different histories.
main ... v1.0

30 changed files with 82 additions and 805 deletions

4
.gitignore vendored
View file

@ -160,7 +160,3 @@ cython_debug/
# option (not recommended) you can uncomment the following to ignore the entire idea folder. # option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/ #.idea/
/tools/
/wobbl_tools/
/Wobbl_Tools/
/settings.txt

View file

@ -2,50 +2,7 @@
Throw the cow as far as you can! Throw the cow as far as you can!
![A cow with a parachute.](https://teapot.informationsanarchistik.de/Wobbl/Cowyeet/raw/branch/main/textures/cow_with%20parachute_.png)
Install the Modules with the following command: Install the Modules with the following command:
``` ```
pip install pynput pip install pynput
``` ```
In versions after 1.0, it will require
[Wobbl Tools.](https://teapot.informationsanarchistik.de/Wobbl/wobbl_tools)
The parabelfunc.py is used to calculate a ballistical curve with parameters for angle, speed, gravity to create a realistic flight.
It returns its coordinates depending on the resolution (xmax-xmin) * (ymax-ymin). So you probably want to keep xmin and ymin at 0.
0/0 is in mathematical representation left/down corner.
The function is called
```
berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe)
```
and returns a list of x and y coordinates: [x1,y1,x2,y2....] like the following example for a display with a width of 10 points/pixel/char/weltraumgnietschies starting with x=0
```
[0, 0, 1, 1.1, 2, 1.7, 3, 2.4, 4, 2.9, 5, 3.5, 6, 4.0, 7, 4.5, 8, 5.0, 9, 5.4]
```
The parameter cow is not useless, it can be set to any singlebyte ASCII string like "*" or some doublespaced UTF8 char like "🐄". If it is a singlechar in ASCII, which is the default, the curve will be calculated with singlesteps, if ist is a UTF8-String, each step will be 2 points, because we now know, we have a textmode display and doublewidth chars.
```
# X-Resolution of the display
cow="🐫"
xmax = 100
ymax = 40
ymin = 0
xmin = 0
startwinkel = 34
startgeschwindigkeit = 31
starthoehe = 0
ergebnis = berechneflugbahn(cow, xmin, xmax, ymin, ymax, startwinkel, startgeschwindigkeit, starthoehe)
for count in range(xmin, len(ergebnis), 2):
x, y = ergebnis[count], ergebnis[count + 1]
curpos(x, y)
print(cow, end="")
```

BIN
boing.mp3

Binary file not shown.

BIN
boing.wav

Binary file not shown.

View file

@ -1,399 +1,118 @@
#!/usr/bin/python3 #!/usr/bin/python3
import os import os
import pygame from time import sleep
import numpy from pynput import keyboard
from tools import pg # if you import pg from tools, you dont need to init pygame.
from tools.file_dict import FileDict
from physics.parabelfunc import berechneflugbahn
# integrated settings (I dont trust my own settings class.)
DEFAULT_WINDOW_SIZE = (800, 600)
FPS = 60 FPS = 60
SAVE_SETTINGS_ON_EXIT = True BLA_SPEED = 1
tx, ty = os.get_terminal_size().columns, os.get_terminal_size().lines
half_tx = round(tx / 2)
bla_pos = 1
bla_back = False
stop = None
yeet = None
yeet_dist = None
pygame.init() # pygame initialization def clear():
screen = pygame.display.set_mode(DEFAULT_WINDOW_SIZE) if os.name == "nt":
pygame.display.set_caption("Cowyeet 2.0") os.system("cls")
else:
os.system("clear")
if os.path.isfile("settings.txt"): # If the settings exist, load them into a dict. Else create the settings with the default values.
settings = FileDict("settings.txt") def on_press(key):
global stop
global yeet_dist
try:
if key == keyboard.Key.space:
if not stop:
stop = bla_pos
bla_dist = half_tx - bla_pos
if bla_dist < 0:
bla_dist = 0 - bla_dist
yeet_dist = tx - 2 - bla_dist * 2 - 10
except AttributeError:
# print('special key {0} pressed'.format(key))
pass
def on_release(key):
# print('{0} released'.format(key))
if key == keyboard.Key.esc:
# Stop listener
return False
def move_bla():
global bla_pos
global bla_back
print(" " * (half_tx - 1) + "")
print(" " * (bla_pos - 1) + "#")
if bla_back:
bla_pos -= BLA_SPEED
else: else:
settings = FileDict() bla_pos += BLA_SPEED
settings.path = "settings.txt"
settings["win_size"] = DEFAULT_WINDOW_SIZE
settings["level_size_multiplier"] = 1
settings.save()
# loading screen if bla_pos >= tx:
default_font = pygame.font.SysFont("ubuntu", 16) bla_back = True
loading_text = default_font.render("Loading...", True, (240, 240, 240))
screen.fill((40, 40, 40)) elif bla_pos <= 1:
screen.blit(loading_text, (400 - loading_text.get_width() / 2, 300 - loading_text.get_height() / 2)) bla_back = False
pygame.display.update()
# /loading screen
# functions
# images
def load_texture(path: str):
if os.path.isfile(path):
return pygame.image.load(path)
else:
return texture_not_found
def load_block_texture(path: str):
texture = load_texture(path)
return pygame.transform.scale(texture, (40 * settings["level_size_multiplier"], 40 * settings["level_size_multiplier"]))
# /images
# coordinate calculations
def center_x(width: int):
return screen.get_width() / 2 - width / 2
def center_y(height: int):
return screen.get_height() / 2 - height / 2
def center(size):
width, height = size
return center_x(width), center_y(height)
# /coordinate calculations
# image calculations
def set_rot_point(img, pos):
w, h = img.get_size()
w, h = w * 2, h * 2
img2 = pygame.Surface((w, h), pygame.SRCALPHA)
img2.blit(img, (w / 2 - pos[0], h / 2 - pos[1]))
return img2, (w, h)
# / image calculations
# game logic
def start_level(lvl: int):
global level
global cow_throwable
page_switch("ingame")
level = lvl
load_level(lvl)
cow_throwable = True
def load_level(lvl):
global level_data
global lvl_width
global level_surface
level_data = __import__("data.levels." + str(lvl), fromlist="data.levels")
lvl_width, lvl_height = level_data.level_size
level_surface = pygame.Surface((lvl_width * 40 * settings["level_size_multiplier"], lvl_height * 40 * settings["level_size_multiplier"]), pygame.SRCALPHA, 32)
x = 0
y = 0
for row in level_data.data_array:
x = 0
for block in row:
rx = x * 40 * settings["level_size_multiplier"]
ry = y * 40 * settings["level_size_multiplier"]
blit_block(block, (rx, ry))
x += 1
y += 1
def blit_block(block, position: tuple):
if not block == 0:
if block == 1:
level_surface.blit(stone_block_texture, position)
elif block == 2:
level_surface.blit(dirt_block_texture, position)
elif block == 3:
level_surface.blit(grass_block_texture, position)
elif block == 4:
level_surface.blit(rock_block_texture, position)
else:
level_surface.blit(texture_not_found, position)
def yeet_cow(): def yeet_cow():
global cow_throwable global yeet
global cow_flying
global cow_flight_path
global cow_flight_step
if cow_throwable:
cow_throwable = False
lvl_x, lvl_y = level_data.level_size
lvl_x *= 40
lvl_x *= settings["level_size_multiplier"]
lvl_y *= 40
lvl_y *= settings["level_size_multiplier"]
cow_flight_path = berechneflugbahn(lvl_x, lvl_y, lvl_x + 100, 34, 128, xstep=10)
cow_flying = True
cow_flight_step = 0
# /game logic
# page system
def main_menu_page():
screen.blit(full_icon_texture, (center_x(full_icon_texture.get_width()), 128))
buttons[start_button].blit()
def level_selector_page():
buttons[lvl_one_button].blit()
screen.blit(choose_level_text, (screen.get_width() / 2 - choose_level_text.get_width() / 2, 16))
def ingame_page():
global cow_flight_step
global cow_position
global cow_flying
global cow_throwable
screen.fill(summer_sky)
screen.blit(level_surface, (0, screen.get_height() - level_surface.get_height()))
lvl_size = settings["level_size_multiplier"]
cx, cy = level_data.catapult_pos
cx = cx * 40 * lvl_size
cy = screen.get_height() - level_surface.get_height() + cy * 40 * lvl_size - catapult_frame_texture.get_height()
screen.blit(catapult_frame_texture, (cx, cy))
screen.blit(catapult_arm_texture, (cx + 27 * 5 * lvl_size, cy - 35 * 5 * lvl_size))
if cow_flying:
cow_flight_step += 1
x = cow_flight_path[cow_flight_step * 2]
y = cow_flight_path[cow_flight_step * 2 + 1]
cow_position = (x, screen.get_height() - y - 64 * 5 * settings["level_size_multiplier"])
if cow_flight_step * 2 == len(cow_flight_path) - 2:
cow_flying = False
cow_throwable = True
screen.blit(cow, cow_position)
def page_selector():
if page == "main_menu":
main_menu_page()
elif page == "level_selector":
level_selector_page()
elif page == "ingame":
ingame_page()
def page_switch(new_page: str=None):
global active_buttons
global page
if not new_page is None:
page = new_page
if page == "main_menu":
active_buttons = [start_button]
elif page == "level_selector":
active_buttons = [lvl_one_button]
elif page == "ingame":
active_buttons = []
# for button in buttons:
# button.active = False
#
# for button in active_buttons:
# button.active = True
# /page system
def close():
global running global running
if not yeet:
yeet = 1
print("-" * (yeet - 1) + "🐄️")
if yeet >= yeet_dist:
running = False running = False
yeet += 1
def window_size_reload(new_size):
for button in text_buttons:
buttons[button].update()
settings["win_size"] = new_size
def get_events():
global last_frame_mouse_pressed
for event in pygame.event.get():
if event.type == pygame.QUIT:
close()
return
if event.type == pygame.MOUSEBUTTONDOWN:
pressed = mouse.get_pressed()
pos = mouse.get_pos()
if not last_frame_mouse_pressed:
for button in active_buttons:
buttons[button].check(pos, pressed)
last_frame_mouse_pressed = True
elif event.type == pygame.VIDEORESIZE:
window_size_reload(event.size)
elif event.type == pygame.KEYDOWN:
key = event.key
if key == pygame.K_c and pressed_special_keys & pygame.KMOD_CTRL:
close()
elif key == pygame.K_SPACE:
if page == "ingame":
yeet_cow()
def loop(): def loop():
global last_frame_mouse_pressed clear()
global pressed_keys
global pressed_special_keys
screen.fill(nero) if not stop:
move_bla()
pressed_keys = keyboard.get_pressed() else:
pressed_special_keys = keyboard.get_mods() yeet_cow()
get_events()
if not running: sleep(1 / FPS)
return
pressed = mouse.get_pressed()
if not pressed[0] and not pressed[1] and not pressed[2]:
last_frame_mouse_pressed = False
page_selector()
pygame.display.update()
clock.tick(FPS)
# variables listener = keyboard.Listener(
nero = (40, 40, 40) # colors (color names by https://www.color-blindness.com/color-name-hue/) on_press=on_press,
dim_gray = (100, 100, 100) on_release=on_release)
summer_sky = (50, 200, 220)
white_smoke = (240, 240, 240)
buttons = [] # misc listener.start()
text_buttons = []
active_buttons = []
last_frame_mouse_pressed = False
page = "main_menu"
level = None
level_data = None
lvl_width = None
level_surface = None
cow_throwable = False
cow_flying = False
cow_position = (0, 0)
cow_flight_path = []
cow_flight_step = 0
pressed_keys = []
pressed_special_keys = pygame.key.get_mods()
# pygame objects
clock = pygame.time.Clock() # misc
mouse = pygame.mouse
keyboard = pygame.key
bigger_default_font = pygame.font.SysFont("ubuntu", 32) # fonts
choose_level_text = bigger_default_font.render("Choose a level:", True, white_smoke) # texts
texture_not_found = pygame.image.load("textures/texture_not_found.png")
texture_not_found = pygame.transform.scale(texture_not_found, (40 * settings["level_size_multiplier"], 40 * settings["level_size_multiplier"]))
icon_texture = load_texture("textures/icon.png")
full_icon_texture = load_texture("textures/icon_full.png")
full_icon_texture = pygame.transform.scale(full_icon_texture, (260, 90))
catapult_frame_texture = load_texture("textures/catapult/frame.png")
catapult_frame_texture = pygame.transform.scale(catapult_frame_texture, (66 * 5 * settings["level_size_multiplier"], 31 * 5 * settings["level_size_multiplier"]))
catapult_arm_texture = load_texture("textures/catapult/arm.png")
catapult_arm_texture = pygame.transform.scale(catapult_arm_texture, (25 * 5 * settings["level_size_multiplier"], 53 * 5 * settings["level_size_multiplier"]))
cow = load_texture("textures/cow/head.png")
cow = pygame.transform.scale(cow, (64 * 5 * settings["level_size_multiplier"], 64 * 5 * settings["level_size_multiplier"]))
stone_block_texture = load_block_texture("textures/terrain/stone_01.png")
dirt_block_texture = load_block_texture("textures/terrain/dirt_01.png")
grass_block_texture = load_block_texture("textures/terrain/grass_01.png")
rock_block_texture = load_block_texture("textures/terrain/rock_01.png")
# buttons
buttons.append(pg.TextButton("Start", center, screen, lambda: page_switch("level_selector"), text_color=white_smoke, bg_color=dim_gray, font=bigger_default_font))
start_button = len(buttons) - 1
text_buttons.append(start_button)
buttons.append(pg.TextButton("1", (128, 128), screen, lambda: start_level(1), text_color=white_smoke, bg_color=dim_gray, font=bigger_default_font, padding=(17, 8)))
lvl_one_button = len(buttons) - 1
text_buttons.append(lvl_one_button)
# /buttons
# /variables
# loading completed
screen = pygame.display.set_mode(settings["win_size"], flags=pygame.RESIZABLE, vsync=1)
window_size_reload(settings["win_size"])
pygame.display.set_icon(icon_texture)
screen.fill(nero)
pygame.display.update()
page_switch("main_menu")
running = True running = True
try:
while running: while running:
loop() loop()
pygame.quit() except KeyboardInterrupt:
clear()
if SAVE_SETTINGS_ON_EXIT: print("Exit.")
settings.save()
print("Bye!")

View file

@ -1,44 +0,0 @@
#!/usr/bin/python3
import numpy
level_size = (64, 32)
catapult_pos = (3, 28)
data_list = [
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 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one",
2: "dirt",
3: "grass",
4: "rock"
}

View file

@ -1,25 +0,0 @@
#!/usr/bin/python3
import pyperclip
width = int(input("Width: "))
height = int(input("Height: "))
print("[")
matrix_str = "[\n"
for bla in range(height):
line = []
for bla in range(width):
line.append(0)
matrix_str += str(line) + ",\n"
print(str(line) + ",")
print("]")
matrix_str += "]"
pyperclip.copy(matrix_str)

View file

@ -1,61 +0,0 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os, sys, termios, tty, time, random
from math import sin, cos, sqrt
from time import sleep
# Randomly choose a cow
cows = "🐵🐒🦍🦧🐕🐯🦝🐩🐅🐴🐎🦄🦌🐗🐂🐃🐄🐪🐫🦙🦒🐹🦘🦡🐧🕊️🦅🦆🦉🐍🦎🐊🦜🦚🦩🐲🐉🦕"
cowslength = len(cows)
cow = cows[random.randint(0, cowslength - 1)]
# cow = "🐄"
# cow = "*"
if cow.isascii():
charlength = 1
else:
charlength = 2
# Needed: find our screensize
termsize_xy = os.get_terminal_size()
# maximum and medium of points in a row
xmax = termsize_xy[0] - 1
xmitte = xmax / 2
# maximum and medium of points in a column
ymax = termsize_xy[1]
ymitte = ymax / 2
# 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"
# pi is not defined by default. Noone has a display with 31416 Pixels in a row. U know better? Enhance it.
pi = 3.1416
# This is for convenience, if you are thinking in degrees. It must not be recalculated every loop.
deg2rad = pi / 180
# position cursor at x,y - where x=0 y=0 is the left lower corner like in mathematical diagrams
# some scales, we need. Those UTF8Cows are 2 chars wide and need more space. So we have to scale one Axis
radius = ymitte - 2
xradius = ymitte * charlength - 1
# Position the curser at x,y. Yes, we start with x, print does not, you are looking right. Leave it this way!
def curpos(x, y):
print("\033[%d;%dH" % (ymax - y, x), end="", flush=True)
print(clear, curoff)
# Draw a circle in maximum 360 Steps, one for for every degree
for winkel in range(0, 359):
x = sin(winkel * deg2rad) * xradius + xmitte
y = cos(winkel * deg2rad) * radius + ymitte
curpos(x, y)
print(cow, end="")
time.sleep(0.01)
curpos(1, 1)
sys.exit(curon + "Schulz nun.")

View file

@ -1,128 +0,0 @@
#!/usr/bin/python3
# -*- coding: utf-8 -*-
import os, sys, termios, tty, time, random
from math import sin, cos, tan, sqrt
from time import sleep
# pi is not defined by default
pi = 3.1416
deg2rad = pi / 180
########################################################################################
def berechneflugbahn(xmax, ymax, steps, startwinkel, startgeschwindigkeit, xmin=0, ymin=0, starthoehe=0, gravitation=9.81, xstep=1):
x = 0
y = x**2
# in scala the resulting coordinates will be returned
scala = []
startwinkel = startwinkel * deg2rad
# Calculate time of flight, actually not used
flugdauer = startgeschwindigkeit * sin(startwinkel) / gravitation
# Calculate maximum height
hoehe = 0.5 * gravitation * flugdauer**2 + starthoehe
# calculate length of flight, actually not used
wurfweite = (
startgeschwindigkeit
* cos(startwinkel)
* (startgeschwindigkeit * sin(startwinkel) + sqrt(startgeschwindigkeit**2 * sin(startwinkel) ** 2 + 2 * gravitation * starthoehe))
) / gravitation
first_run = True
# cowlength is 2, if cow is an UTF8-Icon, otherwise 1
for x in range(xmin, steps - 1, xstep):
# the formula, which generates the y position for the corresponding x, shamelessly ripped from some schoolbook and modified.
y = (-(gravitation / (2 * startgeschwindigkeit**2 * cos(startwinkel) ** 2)) * x**2) + (tan(startwinkel) * x + starthoehe)
# Ensure, that nothing has to be drawn outside the viewport
if x >= 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)

View file

@ -1,128 +0,0 @@
#!/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.")

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 963 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 913 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 577 B