diff --git a/project/level/elements/static/SpikeLevelElement.py b/project/level/elements/static/SpikeLevelElement.py index 672c56f..2a5082a 100644 --- a/project/level/elements/static/SpikeLevelElement.py +++ b/project/level/elements/static/SpikeLevelElement.py @@ -11,6 +11,7 @@ BLOCK_TYPES = { '>': 'small_spike_right' } + class SpikeLevelElement(StaticLevelElement): def __init__(self, tile: dict, loaded_level, level_screen_manager: 'LevelScreenManager'): @@ -22,9 +23,11 @@ class SpikeLevelElement(StaticLevelElement): self.spritesheet = spritesheet_manager.get_sheet(block_type) self.set_animation_state('1') self.position_scale.position = self.tile['position'] + self.bounding_box_margin = (-5, -5) def tick(self, tick_data: TickData): super().tick(tick_data) for collision in self.get_collides_with(): if collision.secondary_sprite.id == 'player': - self.level_screen_manager.player_death() \ No newline at end of file + # print('You dies in ze spikes') + self.level_screen_manager.player_death() diff --git a/project/level/selection/MainMenuScreenManager.py b/project/level/selection/MainMenuScreenManager.py index c11fffd..89964a9 100644 --- a/project/level/selection/MainMenuScreenManager.py +++ b/project/level/selection/MainMenuScreenManager.py @@ -29,6 +29,7 @@ class MainMenuScreenManager(ScreenManager): def create_button(self, name: str, x_position, y_position, font_size): label = TextLabel(name, x_position, y_position, font_size, alignment="center") + label.bounding_box_margin = (10, 18) self.add_element(DrawLayers.UI, label) label.position_scale.scale = (1, 1) if name == "START": diff --git a/project/sprite/Sprite.py b/project/sprite/Sprite.py index e4b321e..b8fe493 100644 --- a/project/sprite/Sprite.py +++ b/project/sprite/Sprite.py @@ -99,10 +99,10 @@ class Sprite(UiElement): if self.bounding_box.x != self.position_scale.position[0] or \ self.bounding_box.y != self.position_scale.position[1]: self.bounding_box = BoundingBox( - self.position_scale.position[0], - self.position_scale.position[1], - self.image.get_width() * self.position_scale.scale[0], - self.image.get_height() * self.position_scale.scale[1] + self.position_scale.position[0] - self.bounding_box_margin[0], + self.position_scale.position[1] - self.bounding_box_margin[1], + self.image.get_width() * self.position_scale.scale[0] + self.bounding_box_margin[0] * 2, + self.image.get_height() * self.position_scale.scale[1] + self.bounding_box_margin[1] * 2 ) return self.bounding_box diff --git a/project/ui_elements/TextLabel.py b/project/ui_elements/TextLabel.py index f985f52..b8d5531 100644 --- a/project/ui_elements/TextLabel.py +++ b/project/ui_elements/TextLabel.py @@ -49,8 +49,8 @@ class TextLabel(UiElement): def get_bounding_box(self) -> BoundingBox: return BoundingBox( - self.position_scale.position[0], - self.position_scale.position[1], - self.current_width * self.position_scale.scale[0], - self.current_height * self.position_scale.scale[1] + self.position_scale.position[0] - self.bounding_box_margin[0], + self.position_scale.position[1] - self.bounding_box_margin[1], + self.current_width * self.position_scale.scale[0] + self.bounding_box_margin[0] * 2, + self.current_height * self.position_scale.scale[1] + self.bounding_box_margin[1] * 2 ) diff --git a/project/ui_elements/UiElement.py b/project/ui_elements/UiElement.py index 84c88e5..268ec02 100644 --- a/project/ui_elements/UiElement.py +++ b/project/ui_elements/UiElement.py @@ -18,6 +18,7 @@ class UiElement: self.click_listeners = [] self.bounding_box = BoundingBox(0, 0, 0, 0) + self.bounding_box_margin = (0, 0) self.uuid = uuid.uuid4()