Example #1
0
 def __init__(self,
              definition_path,
              map_path,
              init_music_path=None,
              music_path=None,
              music_loops=-1,
              has_timer=True,
              should_fade_in=True,
              mid=0):
     self.has_timer = has_timer
     self.keyCode = None
     self.definition_path = definition_path
     self.map_path = map_path
     self.tile_engine = TileEngine(join(Level.MAP_BASE, definition_path),
                                   join(Level.MAP_BASE, map_path))
     self.camera = Camera(self.tile_engine,
                          pygame.Rect(0, 0, Globals.WIDTH, Globals.HEIGHT))
     self.tile_rect = self.tile_engine.get_tile_rect()
     self.enemySprites = pygame.sprite.Group()
     self.playerSprites = pygame.sprite.Group()
     self.turrets = list()
     self.lights = list()
     self.init_player()
     self.init_enemies()
     self.timer = None
     if Globals.HEALTH_BAR is None:
         Globals.HEALTH_BAR = HealthBar()
     if Globals.HUD_MANAGER is None:
         Globals.HUD_MANAGER = HUDManager()
     self.black_surf = pygame.Surface(
         (Globals.WIDTH, Globals.HEIGHT)).convert()
     self.black_surf.fill((0, 0, 0))
     self.fade_in = False
     self.fade_out = False
     self.showing_subtitle = False
     self.alpha_factor = 300
     self.should_fade_in = should_fade_in
     self.pausing = False
     self.going_back = False
     self.score_counted = False
     self.respawn_coords = [-1, -1]
     self.timer = None
     self.first_occur = True
     self.find_respawn()
     self.loader = AssetLoader('images', 'sounds')
     self.switch_sound = self.loader.load_sound(Level.SWITCH_SOUND_PATH)
     self.channel = None
     self.music_loops = music_loops
     self.music_handle = None
     if music_path is not None:
         self.background_music_handle = self.loader.load_sound(music_path)
         self.music_handle = self.background_music_handle
     else:
         self.background_music_handle = None
     if init_music_path is not None:
         self.init_music_handle = self.loader.load_sound(init_music_path)
         self.music_handle = self.init_music_handle
     else:
         self.init_music_handle = None
     self.time_init = 0
     self.start_on_stop = True
     self.switched_sound = False
     self.music_end_id = Level.MUSIC_END_ID_BASE + mid
     self.can_open_doors = True