Ende 11.11.26
This commit is contained in:
parent
99dc8c8a98
commit
ce420d52c6
4 changed files with 25 additions and 4 deletions
BIN
ANLEITUNG_SCHUELER_ANIMATION.pdf
Normal file
BIN
ANLEITUNG_SCHUELER_ANIMATION.pdf
Normal file
Binary file not shown.
3
game.py
3
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
|
||||
"""
|
||||
|
|
|
|||
22
scripts/animation.py
Normal file
22
scripts/animation.py
Normal 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)
|
||||
|
||||
|
||||
|
|
@ -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)
|
||||
Loading…
Reference in a new issue