diff --git a/ANLEITUNG_SCHUELER_ANIMATION.pdf b/ANLEITUNG_SCHUELER_ANIMATION.pdf new file mode 100644 index 0000000..c3372ae Binary files /dev/null and b/ANLEITUNG_SCHUELER_ANIMATION.pdf differ diff --git a/game.py b/game.py index 11d76cd..46c1e8a 100644 --- a/game.py +++ b/game.py @@ -126,6 +126,5 @@ game.run() """ -Wie funktioniert Kollision mit Bildern?????????????????????????!!!!!!!!!!!!!!!!!!!!!!!!!!! -(Günter hat ein Tutorial) +Recherchieren: "Call by reference / Call by value" für copy Methode """ diff --git a/scripts/animation.py b/scripts/animation.py new file mode 100644 index 0000000..b424d65 --- /dev/null +++ b/scripts/animation.py @@ -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) + + diff --git a/scripts/utils.py b/scripts/utils.py index 72aaa19..fd4d286 100644 --- a/scripts/utils.py +++ b/scripts/utils.py @@ -4,10 +4,10 @@ import pygame # 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 / path) return pygame.image.load(images_path / path) \ No newline at end of file