33 lines
1.1 KiB
Python
33 lines
1.1 KiB
Python
|
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 = {
|
||
|
'#': 'block_full',
|
||
|
'+': 'block_top',
|
||
|
'-': 'block_bottom',
|
||
|
'l': 'block_left',
|
||
|
'r': 'block_right',
|
||
|
'~': 'block_top_left',
|
||
|
'|': 'block_top_right'
|
||
|
}
|
||
|
|
||
|
|
||
|
class SimpleBlockLevelElement(StaticLevelElement):
|
||
|
def __init__(self, tile: dict, loaded_level):
|
||
|
super().__init__(tile, loaded_level)
|
||
|
|
||
|
def load(self, sprite_manager: SpriteManager, spritesheet_manager: SpritesheetManager, level: Level):
|
||
|
if self.tile['name'] in BLOCK_TYPES:
|
||
|
block_type = BLOCK_TYPES[self.tile['name']]
|
||
|
else:
|
||
|
block_type = 'block_full'
|
||
|
print(f"Unknown block type: {self.tile['name']} {self.tile['position']}")
|
||
|
|
||
|
self.spritesheet = spritesheet_manager.get_sheet(level.theme + '_' + block_type)
|
||
|
self.set_animation_state(str(random.randint(1, 3)))
|
||
|
self.position_scale.position = self.tile['position']
|