diff --git a/README.md b/README.md index 8a67c1f..38029cd 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,4 @@ Links: - [doc: Software design](https://docs.google.com/document/d/1GpieqcuPjXC1P-a0mXGLe61XF8xzZ_h2taeojuUqToA/edit#heading=h.a6o0m6lt88hs) - [tab: Arbeitspakete](https://docs.google.com/spreadsheets/d/1zyScof0CLPPSmdI0Dq3QWAdLAvyMhk_QFo7VJDFPymk/edit#gid=0) - [tab: Levels](https://docs.google.com/spreadsheets/d/1kIfnlJLYZ0p-zY8Jl699yGgnn6wju2nfAVBx9WdDkQI/edit#gid=741912808) +- [tab: Grafiken](https://docs.google.com/spreadsheets/d/1gT3khuVGXgm-Wk83aEAYn9wOUzQKluHDlfMs6SlZ8KU/edit) diff --git a/project/main.py b/project/main.py index b1b6db5..f098377 100644 --- a/project/main.py +++ b/project/main.py @@ -58,10 +58,11 @@ elif what_to_run == 'physics': test_2_sprite.position_scale = PositionScale((10, 80), (1, 1)) sprite_manager.add_sprite(DrawLayers.OBJECTS, test_2_sprite) - text_1 = TextLabel("Das ist ein Test", 10, 80, 50, alignment="left") + text_1 = TextLabel("Frame: 0", 10, 110, 50, alignment="left") text_1.position_scale.scale = (0.1, 0.1) sprite_manager.add_sprite(DrawLayers.UI, text_1) + counter = 0 while True: clock.tick(frame_rate) @@ -77,6 +78,8 @@ elif what_to_run == 'physics': if skip: continue + counter += 1 + text_1.set_text(f"Frame: {counter}") screen.fill((0, 0, 0)) sprite_manager.tick(apply_frame_rate(1)) diff --git a/project/physics/PhysicsElementsHandler.py b/project/physics/PhysicsElementsHandler.py index 9ac0b7d..b3f93ea 100644 --- a/project/physics/PhysicsElementsHandler.py +++ b/project/physics/PhysicsElementsHandler.py @@ -14,13 +14,13 @@ class PhysicsElementsHandler: def __init__(self): pass - def tick_all_layers(self, dt: float, layers: dict[str, list[UiElement]]): + def tick(self, dt: float, layers: dict[str, list[UiElement]]): + sprites = [] for layer in layers: - self.tick(dt, layers[layer]) - - def tick(self, dt: float, sprites: list[UiElement]): - for sprite in sprites: - sprite.tick(dt) + for sprite in layers[layer]: + sprite.tick(dt) + if isinstance(sprite, Sprite): + sprites.append(sprite) # handle motion and collisions. To do this: # 1. Find all sprites that have collision enabled and store them in a list diff --git a/project/physics/SpriteManager.py b/project/physics/SpriteManager.py index 9540c81..482f3f1 100644 --- a/project/physics/SpriteManager.py +++ b/project/physics/SpriteManager.py @@ -33,7 +33,7 @@ class SpriteManager: self.layers[layer].remove(sprite) def tick(self, dt: float): - self.physics_handler.tick_all_layers(dt, self.layers) + self.physics_handler.tick(dt, self.layers) def draw(self, screen: Surface, screen_transform: PositionScale): for layer in DrawLayers.DRAW_ORDER: