Compare commits

...

59 commits
v1.0 ... main

Author SHA1 Message Date
5a04f262a4 Made it possible to quit the game using CTRL + C. 2024-01-03 20:58:56 +01:00
042e5fa546 Added bye text on exit. 2024-01-02 14:24:10 +01:00
1878c6dd20 Made the cow with the parachute bigger to work in the markdown without css. 2023-12-30 22:20:00 +01:00
65447ae569 README.md aktualisiert
Added the parachute cow to the README.md
2023-12-30 20:12:46 +01:00
685bbd6f09 Added an image of a cow with a parachute. 2023-12-30 19:26:27 +01:00
2fc2b22307 Tried to enable vsync. 2023-12-29 21:18:43 +01:00
ac1b10fd01 It is now possible to yeet the cow's head by pressing space. 2023-12-29 21:10:43 +01:00
82bffd6caf Pi and deg2rad have to be defined if the script is imported too. 2023-12-29 20:43:49 +01:00
cc7685c458 Made some improvements. 2023-12-29 20:31:52 +01:00
72f4674ee1 Made some improvements. 2023-12-29 20:00:39 +01:00
65265c6b02 Removed strange code. 2023-12-29 19:07:26 +01:00
a11fe04cb1 Improved some details. 2023-12-29 19:01:37 +01:00
b8369e0bf8 Made it usable as module. 2023-12-29 18:54:39 +01:00
d085bd72af Created folder called "physics" and moved Wuffel's throwcurve-programs in it. 2023-12-27 19:12:52 +01:00
37b36f2d49 Reformatted the code.
Formatting sequence:
Imports
Classes
Functions
Variables
Start
2023-12-27 17:45:27 +01:00
08b117baf9 Merge remote-tracking branch 'origin/main' 2023-12-04 17:28:52 +01:00
e8bdc8df3e Added cow head texture. 2023-12-04 17:27:03 +01:00
Wolfgang Nowak
818c88e050 aufgehübscht 2023-11-20 15:11:26 +01:00
Wolfgang Nowak
a71b8885e0 Fehler beseitigt 2023-11-20 14:49:07 +01:00
Wolfgang Nowak
e415522916 Fehler beseitigt 2023-11-19 18:53:07 +01:00
Wolfgang Nowak
3d16287c44 Some more content concerning the added parabel funktions 2023-11-19 18:25:08 +01:00
Wolfgang Nowak
cbf7eb60d7 Funktioniert, mit Beispiel 2023-11-19 18:01:30 +01:00
Wolfgang Nowak
0432b4e4f1 Some more content concerning the added parabel funktions 2023-11-19 17:59:57 +01:00
Wolfgang Nowak
8a3c1847ee Merge remote-tracking branch 'origin' 2023-11-19 17:31:34 +01:00
Wolfgang Nowak
2d1c8f7d19 Funktioniert, mit Meispiel 2023-11-19 17:29:23 +01:00
e0c8405e4b Added the catapult frame to the game. 2023-11-19 17:02:17 +01:00
f45c7cf98e Added some catapult textures. 2023-11-19 16:02:56 +01:00
842be84d1f Removed one debug print. 2023-11-19 14:33:39 +01:00
c78b73976a Added big icon to main menu,
Added small icon.
2023-11-19 14:31:16 +01:00
b61d5406d4 Added the icon to the window. 2023-11-18 13:01:55 +01:00
990c8a1ec4 Added Icon. 2023-11-18 12:47:54 +01:00
Wolfgang Nowak
eb7f4b64aa Some content concerning the added parabel funktions 2023-11-18 02:38:18 +01:00
Wolfgang Nowak
9de809e5cc Some content concerning the added parabel funktions 2023-11-18 02:35:58 +01:00
Wolfgang Nowak
edfec76f08 Some content concerning the added parabel funktions 2023-11-18 02:34:38 +01:00
Wolfgang Nowak
609c934caa Some content concerning the added parabel funktions 2023-11-18 02:26:05 +01:00
Wolfgang Nowak
c3f122c46d Parabelfunktion ohne Ausgabe 2023-11-17 21:16:33 +01:00
97762be1fd Parabel als Funktion, aufrufbar, ohne Wiedergabe 2023-11-17 21:02:43 +01:00
Wolfgang Nowak
cbd60f372d mehr kleinigkeiten korrigiert 2023-11-14 16:04:03 +01:00
Wolfgang Nowak
63d7fa486f kleinigkeiten korrigiert 2023-11-14 01:25:31 +01:00
Wolfgang Nowak
d4eb22f246 parabeltest mit korrekten parabeln & parametern 2023-11-13 19:11:51 +01:00
Wolfgang Nowak
a55eabb46d Ein Landesound 2023-11-13 13:52:30 +01:00
Wolfgang Nowak
2a17f94554 Parabel +korrekte params 2023-11-13 13:47:02 +01:00
d4f6235bb8 Added terrain of first level. 2023-11-12 18:15:57 +01:00
f8aa5bd3d9 Made function load_level() work. 2023-11-12 17:13:08 +01:00
d83f4c5cd7 Fixed Crash:
forgot to add some commas in strings in empty_matrix.py.
2023-11-12 17:04:46 +01:00
a7a22856c9 Added level loading function,
added some textures.
2023-11-12 16:58:39 +01:00
44c8ba0231 Added Level selection. 2023-11-12 15:38:08 +01:00
a9e4b1921b Created some terrain textures. 2023-11-11 22:18:50 +01:00
8645c526f3 Added textures folder,
Created texture for the catapult arm.
2023-11-11 21:49:26 +01:00
Wolfgang Nowak
bdcca10d76 Parabel 2023-11-11 20:55:24 +01:00
9b2fe07fca Fixed bug that only the buttons in the button list got updated. 2023-11-11 20:28:00 +01:00
6b69d32ad1 Merge remote-tracking branch 'origin/main' 2023-11-09 17:24:52 +01:00
53ab1dae11 Finished main menu. 2023-11-09 17:20:51 +01:00
Wolfgang Nowak
69a8e0bd9b Kuhschleudern 2023-11-06 21:55:46 +01:00
237b619eb7 Tiny GUI setup 2023-11-05 19:44:35 +01:00
530a7f49f9 Added settings.txt to .gitignore. 2023-11-05 19:42:45 +01:00
8b8ad6745c Added wobbl_tools folder to .gitignore. 2023-11-05 18:10:11 +01:00
28154248e5 Deleted old code. 2023-11-05 18:06:20 +01:00
7f95f87baa README.md aktualisiert 2023-11-04 12:56:33 +01:00
30 changed files with 805 additions and 82 deletions

4
.gitignore vendored
View file

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

View file

@ -2,7 +2,50 @@
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:
```
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 Normal file

Binary file not shown.

BIN
boing.wav Normal file

Binary file not shown.

View file

@ -1,118 +1,399 @@
#!/usr/bin/python3
import os
from time import sleep
from pynput import keyboard
import pygame
import numpy
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
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
SAVE_SETTINGS_ON_EXIT = True
def clear():
if os.name == "nt":
os.system("cls")
else:
os.system("clear")
pygame.init() # pygame initialization
screen = pygame.display.set_mode(DEFAULT_WINDOW_SIZE)
pygame.display.set_caption("Cowyeet 2.0")
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")
else:
settings = FileDict()
settings.path = "settings.txt"
settings["win_size"] = DEFAULT_WINDOW_SIZE
settings["level_size_multiplier"] = 1
settings.save()
# loading screen
default_font = pygame.font.SysFont("ubuntu", 16)
loading_text = default_font.render("Loading...", True, (240, 240, 240))
screen.fill((40, 40, 40))
screen.blit(loading_text, (400 - loading_text.get_width() / 2, 300 - loading_text.get_height() / 2))
pygame.display.update()
# /loading screen
def on_press(key):
global stop
global yeet_dist
# functions
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
# images
def load_texture(path: str):
if os.path.isfile(path):
return pygame.image.load(path)
else:
bla_pos += BLA_SPEED
return texture_not_found
if bla_pos >= tx:
bla_back = True
elif bla_pos <= 1:
bla_back = False
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():
global yeet
global cow_throwable
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
running = False
if not yeet:
yeet = 1
print("-" * (yeet - 1) + "🐄️")
def window_size_reload(new_size):
for button in text_buttons:
buttons[button].update()
if yeet >= yeet_dist:
running = False
settings["win_size"] = new_size
yeet += 1
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():
clear()
global last_frame_mouse_pressed
global pressed_keys
global pressed_special_keys
if not stop:
move_bla()
screen.fill(nero)
else:
yeet_cow()
pressed_keys = keyboard.get_pressed()
pressed_special_keys = keyboard.get_mods()
get_events()
sleep(1 / FPS)
if not running:
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)
listener = keyboard.Listener(
on_press=on_press,
on_release=on_release)
# variables
nero = (40, 40, 40) # colors (color names by https://www.color-blindness.com/color-name-hue/)
dim_gray = (100, 100, 100)
summer_sky = (50, 200, 220)
white_smoke = (240, 240, 240)
listener.start()
buttons = [] # misc
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
try:
while running:
loop()
while running:
loop()
except KeyboardInterrupt:
clear()
print("Exit.")
pygame.quit()
if SAVE_SETTINGS_ON_EXIT:
settings.save()
print("Bye!")

44
data/levels/1.py Normal file
View file

@ -0,0 +1,44 @@
#!/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, 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, 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, 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, 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, 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, 0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, 2, 2, 2, 2, 2],
[2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2],
[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]
]
data_array = numpy.array(data_list)
matrix = numpy.mat(data_array)

9
data/num_to_name.py Normal file
View file

@ -0,0 +1,9 @@
#!/usr/bin/python3
data = {
0: "air",
1: "stone",
2: "dirt",
3: "grass",
4: "rock"
}

25
empty_matrix.py Normal file
View file

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

61
physics/kreis.py Executable file
View file

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

128
physics/parabelfunc.py Executable file
View file

@ -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
# 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)

128
physics/parabeltest.py Executable file
View file

@ -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.")

BIN
textures/catapult/arm.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

BIN
textures/catapult/frame.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 963 B

BIN
textures/cow/head.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

Binary file not shown.

Binary file not shown.

BIN
textures/gimp/cow/head.xcf Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

BIN
textures/icon.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 913 B

BIN
textures/icon_full.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 671 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 652 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 702 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 577 B