From e4c2007928122d8156100a0f3088dc68f2b6c7fd Mon Sep 17 00:00:00 2001 From: Stephan Halder <2121472@stud.hs-mannheim.de> Date: Tue, 28 Mar 2023 18:09:29 +0200 Subject: [PATCH] GoalDoorReceiverLevelElement added --- project/data/sprites/sprites.json | 10 +++++----- project/level/elements/LoadedLevel.py | 4 ++++ .../static/GoalDoorReceiverLevelElement.py | 20 +++++++++++++++++++ 3 files changed, 29 insertions(+), 5 deletions(-) create mode 100644 project/level/elements/static/GoalDoorReceiverLevelElement.py 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