diff --git a/project/data/sprites/sprites.json b/project/data/sprites/sprites.json index b508e98..fcb30ce 100644 --- a/project/data/sprites/sprites.json +++ b/project/data/sprites/sprites.json @@ -21,16 +21,16 @@ "delays": [ 1 ], - "width": 12, - "height": 12 + "width": 24, + "height": 36 }, { - "id": "closed", + "id": "close", "delays": [ 1 ], - "width": 12, - "height": 12 + "width": 24, + "height": 36 } ] }, diff --git a/project/level/elements/LoadedLevel.py b/project/level/elements/LoadedLevel.py index 5dfbebe..198280a 100644 --- a/project/level/elements/LoadedLevel.py +++ b/project/level/elements/LoadedLevel.py @@ -3,6 +3,7 @@ from typing import Optional from level.Level import Level from level.elements.dynamic.BouncingBallLevelElement import BouncingBallLevelElement from level.elements.dynamic.PushableBoxLevelElement import PushableBoxLevelElement +from level.elements.static.GoalDoorReceiverLevelElement import GoalDoorReceiverLevelElement from level.elements.static.SpikeLevelElement import SpikeLevelElement from level.elements.static.ButtonInputLevelElement import ButtonInputLevelElement from level.elements.static.GateReceiverLevelElement import GateReceiverLevelElement @@ -28,6 +29,8 @@ TILES = { 'G': GateReceiverLevelElement, + 'D': GoalDoorReceiverLevelElement, + 'M': PushableBoxLevelElement, 'q': BouncingBallLevelElement, @@ -101,3 +104,4 @@ class LoadedLevel: for block in self.blocks: self.sprite_manager.remove_ui_element(block) del self.blocks + self.blocks = [] diff --git a/project/level/elements/static/GoalDoorReceiverLevelElement.py b/project/level/elements/static/GoalDoorReceiverLevelElement.py new file mode 100644 index 0000000..738e605 --- /dev/null +++ b/project/level/elements/static/GoalDoorReceiverLevelElement.py @@ -0,0 +1,20 @@ +from level.Level import Level +from level.elements.static.ReceiverLevelElement import ReceiverLevelElement +from physics.SpriteManager import SpriteManager +from sprite.SpritesheetManager import SpritesheetManager + + +class GoalDoorReceiverLevelElement(ReceiverLevelElement): + def __init__(self, tile: dict, level: Level): + super().__init__(tile, level) + + def load(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, level: Level): + self.spritesheet = spritesheet_manager.get_sheet('goal_door') + self.set_animation_state('open' if self.active_state else 'close') + self.position_scale.position = self.tile['position'] + + def set_active(self, active: bool): + super().set_active(active) + self.set_animation_state('open' if self.active_state else 'close') + self.is_collider = not self.active_state + self.register_collisions = self.is_collider