GoalDoorReceiverLevelElement added

main
Stephan Halder 2023-03-28 18:09:29 +02:00
parent 139fa557a9
commit e4c2007928
3 changed files with 29 additions and 5 deletions

View File

@ -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
}
]
},

View File

@ -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 = []

View File

@ -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