def setup(self): super(PVZMainScreen, self).setup() # Preload monster sprites meteormon_img = os.path.join("sample_sprites", "notmine", "meteormon_clueless.png") bakemon_img = os.path.join("sample_sprites", "notmine", "bakemon_attack.png") lalamon_img = os.path.join("sample_sprites", "notmine", "lalamon_clueless.png") tentacly_img = os.path.join("sample_sprites", "notmine", "tentacly_angry.png") self.__monster_list = [meteormon_img, bakemon_img, lalamon_img, tentacly_img] # Load the character sprite shooter_image = Image(os.path.join("sample_sprites", "notmine", "seahomon_hero.png")) shooter_image.flip(True, False) shooter_image.position = Point(0, super(PVZMainScreen, self).screen_size[GameConfig.HEIGHT_INDEX] / 2) self.__shooter_sprite = Shooter(7, shooter_image, 10, self.screen_size[GameConfig.WIDTH_INDEX]) self.player_sprite_group.add(self.shooter_sprite)
from components.image import Image import os import pygame """ Image exception test results. Scenario: File specified does not exist. In this case, the call to pygame.image.load ... already throws an Exception and it is pointless to throw our own custom Exception. Scenario: File specified is deleted after load. Does not seem to affect program flow in any way. Also, this resource does not seem to need closing. @author Chad Estioco """ pygame.display.set_mode([500, 500]) nonexistent = Image(os.path.join("sample_sprites", "lalamon_clueless.png")); # Set-up blocking code... foo = raw_input("Press enter when you have moved lalamon_clueless.png"); nonexistent.flip(True, False) print "If you got here, deleting the resource does nothing."