From 8cbf623247161c54272937d3e2881d5459c364c6 Mon Sep 17 00:00:00 2001 From: Yan Wittmann Date: Sat, 25 Mar 2023 18:27:54 +0100 Subject: [PATCH] Made simulation even more satisfying --- project/main.py | 2 +- project/physics/PhysicsElementsHandler.py | 1 - project/sprite/DynamicSprite.py | 6 ------ 3 files changed, 1 insertion(+), 8 deletions(-) diff --git a/project/main.py b/project/main.py index 863b390..bd4d077 100644 --- a/project/main.py +++ b/project/main.py @@ -38,7 +38,7 @@ elif what_to_run == 'physics': screen = pygame.display.set_mode((600, 500)) pygame.display.set_caption("PM GAME") clock = pygame.time.Clock() - frame_rate = 60 + frame_rate = 59.52 spritesheet_manager = SpritesheetManager("data/sprites", "data/sprites/sprites.json") diff --git a/project/physics/PhysicsElementsHandler.py b/project/physics/PhysicsElementsHandler.py index da29ea3..793faf5 100644 --- a/project/physics/PhysicsElementsHandler.py +++ b/project/physics/PhysicsElementsHandler.py @@ -45,7 +45,6 @@ class PhysicsElementsHandler: def attempt_move(self, dt: float, sprite: DynamicSprite, colliders: list[StaticSprite], motion_steps: int) -> bool: total_motion = sprite.motion motion_step = ((total_motion[0] * dt) / motion_steps, (total_motion[1] * dt) / motion_steps) - print(motion_step) for i in range(motion_steps): sprite.reset_touches() diff --git a/project/sprite/DynamicSprite.py b/project/sprite/DynamicSprite.py index a3c7651..72740ad 100644 --- a/project/sprite/DynamicSprite.py +++ b/project/sprite/DynamicSprite.py @@ -39,12 +39,6 @@ class DynamicSprite(StaticSprite): def tick(self, dt: float): super().tick(dt) - # self.motion = ( - # self.motion[0] - self.deceleration_horizontal * dt, - # self.motion[1] + self.gravity * dt - # ) - # wrong implementation. Make deceleration_horizontal only until 0 is reached. multiply value with motion - deceleration_horizontal = 0 if abs(self.motion[0]) > 0: if self.touches_bounding[2]: