diff --git a/project/level/elements/LoadedLevel.py b/project/level/elements/LoadedLevel.py index 6d29923..81b6cf6 100644 --- a/project/level/elements/LoadedLevel.py +++ b/project/level/elements/LoadedLevel.py @@ -53,7 +53,8 @@ class LoadedLevel: if isinstance(element, SimpleBlockLevelElement): if self.is_surrounded_by_blocks(world_position, level.tiles): element.is_collider = False - #self.sprite_manager.remove_ui_element(element) + element.register_collisions = False + # self.sprite_manager.remove_ui_element(element) def is_surrounded_by_blocks(self, position, tiles): for i in range(-1, 2): diff --git a/project/physics/PhysicsElementsHandler.py b/project/physics/PhysicsElementsHandler.py index 5d13720..e513a88 100644 --- a/project/physics/PhysicsElementsHandler.py +++ b/project/physics/PhysicsElementsHandler.py @@ -1,3 +1,4 @@ +import math from typing import Optional from physics.CollisionDirection import CollisionDirection @@ -161,9 +162,16 @@ class PhysicsElementsHandler: for collider in colliders: if sprite is not collider: + distance = self.calculate_basic_distance(sprite, collider) + if distance > 50: + continue if sprite.collides_with(collider, TOLERANCE): collides_with.append(collider) if len(collides_with) >= 2: break return collides_with + + def calculate_basic_distance(self, sprite1: StaticSprite, sprite2: StaticSprite) -> float: + return math.sqrt((sprite1.position_scale.position[0] - sprite2.position_scale.position[0]) ** 2 + + (sprite1.position_scale.position[1] - sprite2.position_scale.position[1]) ** 2)