diff --git a/robotgame/level2.py b/robotgame/level2.py index c3e7e88..c429d9e 100644 --- a/robotgame/level2.py +++ b/robotgame/level2.py @@ -45,45 +45,6 @@ class Level2(level.Level): anim='lever_updown')) - def load(self): - """Load all resources used in the level.""" - tile_list = ['ground1', 'ground2'] - - for tile in tile_list: - self.imgs[tile] = pygame.image.load(os.path.join( - self.graphics_dir, 'tiles', '%s.png' % tile)) - - block_list = ['block1'] - for block in block_list: - self.imgs[block] = pygame.image.load(os.path.join( - self.graphics_dir, 'blocks', '%s.png' % block)) - - # Load animations - for anim, directory in ( - [('lever_updown', os.path.join('lever', 'down-up')), - ] - ): - - self.imgs[anim] = [] - - # Find all image files for the given animation - anim_files = [] - for root, dirs, files in os.walk(os.path.join( - self.graphics_dir, directory)): - for f in files: - if re.match(r"^.*\.(png)$", '/'.join([root, f])): - anim_files.append('/'.join([root, f])) - - # Sort and load the files - for f in sorted(anim_files): - img = pygame.image.load(f) - - # Special treatment: - if anim == 'arrow_left': - img = pygame.transform.flip(img, 1, 0) - - self.imgs[anim].append(img) - def restart(self): for obj in self.objects: obj.reset_pos() diff --git a/robotgame/level3.py b/robotgame/level3.py index 8c59e76..dfbfca8 100644 --- a/robotgame/level3.py +++ b/robotgame/level3.py @@ -111,45 +111,6 @@ class Level3(level.Level): b.action = update_wells - def load(self): - """Load all resources used in the level.""" - tile_list = ['ground1', 'ground2'] - - for tile in tile_list: - self.imgs[tile] = pygame.image.load(os.path.join( - self.graphics_dir, 'tiles', '%s.png' % tile)) - - block_list = ['block1', 'block1_lifted'] - for block in block_list: - self.imgs[block] = pygame.image.load(os.path.join( - self.graphics_dir, 'blocks', '%s.png' % block)) - - # Load animations - for anim, directory in ( - [('lever_updown', os.path.join('lever', 'down-up')), - ] - ): - - self.imgs[anim] = [] - - # Find all image files for the given animation - anim_files = [] - for root, dirs, files in os.walk(os.path.join( - self.graphics_dir, directory)): - for f in files: - if re.match(r"^.*\.(png)$", '/'.join([root, f])): - anim_files.append('/'.join([root, f])) - - # Sort and load the files - for f in sorted(anim_files): - img = pygame.image.load(f) - - # Special treatment: - if anim == 'arrow_left': - img = pygame.transform.flip(img, 1, 0) - - self.imgs[anim].append(img) - def restart(self): for obj in self.objects: obj.reset_pos() diff --git a/robotgame/level_bonus.py b/robotgame/level_bonus.py index 020ae2a..b7c82b8 100644 --- a/robotgame/level_bonus.py +++ b/robotgame/level_bonus.py @@ -73,46 +73,6 @@ class Level(level.Level): toggling=False, anim='lever_updown')) - - def load(self): - """Load all resources used in the level.""" - tile_list = ['ground1', 'ground2'] - - for tile in tile_list: - self.imgs[tile] = pygame.image.load(os.path.join( - self.graphics_dir, 'tiles', '%s.png' % tile)) - - block_list = ['block1', 'block1_lifted'] - for block in block_list: - self.imgs[block] = pygame.image.load(os.path.join( - self.graphics_dir, 'blocks', '%s.png' % block)) - - # Load animations - for anim, directory in ( - [('lever_updown', os.path.join('lever', 'down-up')), - ] - ): - - self.imgs[anim] = [] - - # Find all image files for the given animation - anim_files = [] - for root, dirs, files in os.walk(os.path.join( - self.graphics_dir, directory)): - for f in files: - if re.match(r"^.*\.(png)$", '/'.join([root, f])): - anim_files.append('/'.join([root, f])) - - # Sort and load the files - for f in sorted(anim_files): - img = pygame.image.load(f) - - # Special treatment: - if anim == 'arrow_left': - img = pygame.transform.flip(img, 1, 0) - - self.imgs[anim].append(img) - def enter(self, root_level): self.__dict__.update(locals()) self.game.objs.remove(root_level)