Vacuum Cleaner added to the game
parent
e9e36c1d50
commit
2c63e34bba
|
@ -141,7 +141,7 @@
|
|||
{
|
||||
"id": "off",
|
||||
"delays": [
|
||||
20
|
||||
30
|
||||
],
|
||||
"width": 48,
|
||||
"height": 36
|
||||
|
|
|
@ -3,19 +3,39 @@ from level.elements.static.StaticLevelElement import StaticLevelElement
|
|||
from physics.SpriteManager import SpriteManager
|
||||
from sprite.SpritesheetManager import SpritesheetManager
|
||||
|
||||
from project.physics.TickData import TickData
|
||||
|
||||
BLOCK_TYPES = {
|
||||
'A': 'staubsauger'
|
||||
}
|
||||
|
||||
|
||||
class VacuumCleanerElement(StaticLevelElement):
|
||||
|
||||
def __init__(self, tile: dict, loaded_level, level_screen_manager: 'LevelScreenManager'):
|
||||
super().__init__(tile, loaded_level, level_screen_manager)
|
||||
self.animation_state_counter = 0
|
||||
self.danger = True
|
||||
self.danger_time = 30
|
||||
self.off_time = 50
|
||||
|
||||
def tick(self, tick_data: TickData):
|
||||
super().tick(tick_data)
|
||||
self.animation_state_counter += tick_data.dt
|
||||
if self.danger:
|
||||
if self.animation_state_counter >= self.danger_time:
|
||||
self.set_animation_state('off')
|
||||
self.animation_state_counter = 0
|
||||
self.danger = not self.danger
|
||||
else:
|
||||
if self.animation_state_counter >= self.off_time:
|
||||
self.set_animation_state('on')
|
||||
self.animation_state_counter = 0
|
||||
self.danger = not self.danger
|
||||
|
||||
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('on')
|
||||
|
||||
self.position_scale.position = self.tile['position']
|
Loading…
Reference in New Issue