Ende 11.11.26

This commit is contained in:
Benjamin 2026-11-11 18:32:27 +01:00
parent 99dc8c8a98
commit ce420d52c6
4 changed files with 25 additions and 4 deletions

Binary file not shown.

View file

@ -126,6 +126,5 @@ game.run()
""" """
Wie funktioniert Kollision mit Bildern?????????????????????????!!!!!!!!!!!!!!!!!!!!!!!!!!! Recherchieren: "Call by reference / Call by value" für copy Methode
(Günter hat ein Tutorial)
""" """

22
scripts/animation.py Normal file
View file

@ -0,0 +1,22 @@
import math
class Animation:
def __init__(self, images, image_duration=0.125, loop=True):
if not images:
raise ValueError("Eine Animation benötigt mindestens ein Bild.")
if not math.isfinite(image_duration) or image_duration <= 0:
raise ValueError("Die Bilddauer muss endlich und größer als null sein.")
self.images = images
self.image_duration = image_duration
self.loop = loop
self.time = 0.0
self.done = False
def copy(self):
return Animation(self.images, self.image_duration, self.loop)

View file

@ -4,10 +4,10 @@ import pygame
# Einheitlichkeit: Wenn image_path ein Path-Objekt ist, sollte auch load_image ein Path-Objekt laden. # Einheitlichkeit: Wenn image_path ein Path-Objekt ist, sollte auch load_image ein Path-Objekt laden.
images_path = Path("./data/textures/") images_path = Path(__file__).resolve().parent.parent / "data" / "textures"
def load_image(path: str) -> pygame.Surface: def load_image(path: str | Path) -> pygame.Surface:
# print(self.images_path) # print(self.images_path)
# print(self.images_path / path) # print(self.images_path / path)
return pygame.image.load(images_path / path) return pygame.image.load(images_path / path)