2023-03-28 17:26:47 +02:00
|
|
|
from level.Level import Level
|
|
|
|
from level.elements.static.StaticLevelElement import StaticLevelElement
|
|
|
|
from physics.SpriteManager import SpriteManager
|
2023-03-29 15:40:15 +02:00
|
|
|
from physics.TickData import TickData
|
2023-03-28 17:26:47 +02:00
|
|
|
from sprite.SpritesheetManager import SpritesheetManager
|
|
|
|
|
|
|
|
BLOCK_TYPES = {
|
|
|
|
'S': 'small_spike_up',
|
|
|
|
's': 'small_spike_down',
|
|
|
|
'<': 'small_spike_left',
|
|
|
|
'>': 'small_spike_right'
|
|
|
|
}
|
|
|
|
|
2023-03-29 23:00:53 +02:00
|
|
|
|
2023-03-28 17:26:47 +02:00
|
|
|
class SpikeLevelElement(StaticLevelElement):
|
|
|
|
|
2023-03-29 15:40:15 +02:00
|
|
|
def __init__(self, tile: dict, loaded_level, level_screen_manager: 'LevelScreenManager'):
|
|
|
|
super().__init__(tile, loaded_level, level_screen_manager)
|
2023-03-28 17:26:47 +02:00
|
|
|
|
|
|
|
def load(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, level: Level):
|
|
|
|
block_type = BLOCK_TYPES[self.tile['name']]
|
|
|
|
|
|
|
|
self.spritesheet = spritesheet_manager.get_sheet(block_type)
|
|
|
|
self.set_animation_state('1')
|
2023-03-29 15:40:15 +02:00
|
|
|
self.position_scale.position = self.tile['position']
|
2023-03-29 23:00:53 +02:00
|
|
|
self.bounding_box_margin = (-5, -5)
|
2023-03-29 15:40:15 +02:00
|
|
|
|
|
|
|
def tick(self, tick_data: TickData):
|
|
|
|
super().tick(tick_data)
|
|
|
|
for collision in self.get_collides_with():
|
|
|
|
if collision.secondary_sprite.id == 'player':
|
2023-03-29 23:00:53 +02:00
|
|
|
# print('You dies in ze spikes')
|
|
|
|
self.level_screen_manager.player_death()
|