Merge remote-tracking branch 'origin/main'
commit
f79c1f6c9d
|
@ -11,6 +11,7 @@ BLOCK_TYPES = {
|
||||||
'>': 'small_spike_right'
|
'>': 'small_spike_right'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
class SpikeLevelElement(StaticLevelElement):
|
class SpikeLevelElement(StaticLevelElement):
|
||||||
|
|
||||||
def __init__(self, tile: dict, loaded_level, level_screen_manager: 'LevelScreenManager'):
|
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.spritesheet = spritesheet_manager.get_sheet(block_type)
|
||||||
self.set_animation_state('1')
|
self.set_animation_state('1')
|
||||||
self.position_scale.position = self.tile['position']
|
self.position_scale.position = self.tile['position']
|
||||||
|
self.bounding_box_margin = (-5, -5)
|
||||||
|
|
||||||
def tick(self, tick_data: TickData):
|
def tick(self, tick_data: TickData):
|
||||||
super().tick(tick_data)
|
super().tick(tick_data)
|
||||||
for collision in self.get_collides_with():
|
for collision in self.get_collides_with():
|
||||||
if collision.secondary_sprite.id == 'player':
|
if collision.secondary_sprite.id == 'player':
|
||||||
self.level_screen_manager.player_death()
|
# print('You dies in ze spikes')
|
||||||
|
self.level_screen_manager.player_death()
|
||||||
|
|
|
@ -29,6 +29,7 @@ class MainMenuScreenManager(ScreenManager):
|
||||||
|
|
||||||
def create_button(self, name: str, x_position, y_position, font_size):
|
def create_button(self, name: str, x_position, y_position, font_size):
|
||||||
label = TextLabel(name, x_position, y_position, font_size, alignment="center")
|
label = TextLabel(name, x_position, y_position, font_size, alignment="center")
|
||||||
|
label.bounding_box_margin = (10, 18)
|
||||||
self.add_element(DrawLayers.UI, label)
|
self.add_element(DrawLayers.UI, label)
|
||||||
label.position_scale.scale = (1, 1)
|
label.position_scale.scale = (1, 1)
|
||||||
if name == "START":
|
if name == "START":
|
||||||
|
|
|
@ -99,10 +99,10 @@ class Sprite(UiElement):
|
||||||
if self.bounding_box.x != self.position_scale.position[0] or \
|
if self.bounding_box.x != self.position_scale.position[0] or \
|
||||||
self.bounding_box.y != self.position_scale.position[1]:
|
self.bounding_box.y != self.position_scale.position[1]:
|
||||||
self.bounding_box = BoundingBox(
|
self.bounding_box = BoundingBox(
|
||||||
self.position_scale.position[0],
|
self.position_scale.position[0] - self.bounding_box_margin[0],
|
||||||
self.position_scale.position[1],
|
self.position_scale.position[1] - self.bounding_box_margin[1],
|
||||||
self.image.get_width() * self.position_scale.scale[0],
|
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.image.get_height() * self.position_scale.scale[1] + self.bounding_box_margin[1] * 2
|
||||||
)
|
)
|
||||||
|
|
||||||
return self.bounding_box
|
return self.bounding_box
|
||||||
|
|
|
@ -49,8 +49,8 @@ class TextLabel(UiElement):
|
||||||
|
|
||||||
def get_bounding_box(self) -> BoundingBox:
|
def get_bounding_box(self) -> BoundingBox:
|
||||||
return BoundingBox(
|
return BoundingBox(
|
||||||
self.position_scale.position[0],
|
self.position_scale.position[0] - self.bounding_box_margin[0],
|
||||||
self.position_scale.position[1],
|
self.position_scale.position[1] - self.bounding_box_margin[1],
|
||||||
self.current_width * self.position_scale.scale[0],
|
self.current_width * self.position_scale.scale[0] + self.bounding_box_margin[0] * 2,
|
||||||
self.current_height * self.position_scale.scale[1]
|
self.current_height * self.position_scale.scale[1] + self.bounding_box_margin[1] * 2
|
||||||
)
|
)
|
||||||
|
|
|
@ -18,6 +18,7 @@ class UiElement:
|
||||||
self.click_listeners = []
|
self.click_listeners = []
|
||||||
|
|
||||||
self.bounding_box = BoundingBox(0, 0, 0, 0)
|
self.bounding_box = BoundingBox(0, 0, 0, 0)
|
||||||
|
self.bounding_box_margin = (0, 0)
|
||||||
|
|
||||||
self.uuid = uuid.uuid4()
|
self.uuid = uuid.uuid4()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue