sep-pm-platformer/project/level/elements/static/SpikeLevelElement.py

25 lines
824 B
Python
Raw Normal View History

2023-03-28 17:26:47 +02:00
import random
from level.Level import Level
from level.elements.static.StaticLevelElement import StaticLevelElement
from physics.SpriteManager import SpriteManager
from sprite.SpritesheetManager import SpritesheetManager
BLOCK_TYPES = {
'S': 'small_spike_up',
's': 'small_spike_down',
'<': 'small_spike_left',
'>': 'small_spike_right'
}
class SpikeLevelElement(StaticLevelElement):
def __init__(self, tile: dict, loaded_level):
super().__init__(tile, loaded_level)
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')
self.position_scale.position = self.tile['position']