def prepare_assets(self): """ This is where you should be loading all your assets/fonts/images etc...""" self.ttl = 5 # TTL in seconds self.background = pygame.image.load( utils.get_asset_path('Alien Oddity.png')) self.background_sound = pygame.mixer.Sound( utils.get_asset_path('game_title_sound.ogg'))
def prepare_assets(self): MusicManager().prepare(MUSIC_MENU) self.background = pygame.image.load( utils.get_asset_path('igor_bg_menu2.jpg')) # self.background = pygame.transform.scale(self.background, (SCREEN_WIDTH, SCREEN_HEIGHT)) print("here1")
def __init__(self, image, x, y, hp): super(Enemy, self).__init__(image, x, y) self.max_hp = hp self.hp = hp self.alpha = 255 self.change_in_y = 1 self.jump_up = True self.impact_sound = pygame.mixer.Sound( utils.get_asset_path('394213__chance4doom__bullet-impact-1.ogg')) self.can_shoot = False self.can_jump = True
def __init__(self, image, x, y, value): super(Collectible, self).__init__(image, x, y) self.value = value self.sound = pygame.mixer.Sound( utils.get_asset_path('ring_inventory.wav'))
def prepare(self, music_type): stack = self.music[music_type] self.filename = utils.get_asset_path( self.get_random_track_from_stack(stack)) self.background_music_pending = pygame.mixer.music.load( self.filename)
def __init__(self, file_name): """ Constructor. Pass in the file name of the sprite sheet. """ # Load the sprite sheet. self.sprite_sheet = pygame.image.load( utils.get_asset_path(file_name)).convert_alpha()
def __init__(self): """ Constructor function """ # Call the parent's constructor super().__init__() # -- Attributes # Set speed vector of player self.change_x = 0 self.change_y = 0 # This holds all the images for the animated walk left/right # of our player self.state_frames = dict() self.state = P_STATE_NORMAL self.old_state = P_STATE_NORMAL # What direction is the player facing? self.direction = "R" self.money = 0 # List of sprites we can bump against self.level = None self.state_frames = { P_STATE_NORMAL: { "R": self.get_walking_frames("p1_walk.png"), "L": self.get_walking_frames("p1_walk.png", True) }, P_STATE_SHOOTING: { "R": self.get_walking_frames("p1_shoot.png"), "L": self.get_walking_frames("p1_shoot.png", True) }, P_STATE_DAMAGE: { "R": self.get_walking_frames("p1_damage.png"), "L": self.get_walking_frames("p1_damage.png", True) }, P_STATE_NORMAL_90: { "R": self.get_walking_frames("p1_walk_90.png"), "L": self.get_walking_frames("p1_walk_90.png", True) }, P_STATE_NORMAL_50: { "R": self.get_walking_frames("p1_walk_50.png"), "L": self.get_walking_frames("p1_walk_50.png", True) }, P_STATE_NORMAL_30: { "R": self.get_walking_frames("p1_walk_30.png"), "L": self.get_walking_frames("p1_walk_30.png", True) }, } # Set the image the player starts with self.image = self.get_frames()[0] # Set a reference to the image rect. self.rect = self.image.get_rect() self.shooting = False self.max_hp = 50 self.hp = self.max_hp self.shooting_sound_start = pygame.mixer.Sound( utils.get_asset_path('196907__dpoggioli__laser-gun-recharge.wav')) self.shooting_sound_continuous = pygame.mixer.Sound( utils.get_asset_path('146725__fins__laser.wav')) self.channel_1 = pygame.mixer.Channel(0) # argument must be int self.channel_2 = pygame.mixer.Channel(1)