def create_player_image(self): self.life_times_image = game_functions.get_image( settings.GFX['text_images'], 75, 247, 6, 6, (92, 148, 252), 2.9) self.life_times_rect = self.life_times_image.get_rect(center=(378, 295)) self.life_total_label = [] self.create_label(self.life_total_label, str(self.total_lives), 450, 285) if self.game_info[c.PLAYER_NAME] == c.PLAYER_MARIO: rect = (178, 32, 12, 16) else: rect = (178, 128, 12, 16) self.player_image = game_functions.get_image( settings.GFX['mario_bros'], *rect, (92, 148, 252), 2.9) self.player_rect = self.player_image.get_rect(center=(320, 290))
def setup_cursor(self): self.cursor = pygame.sprite.Sprite() self.cursor.image = game_functions.get_image( settings.GFX[c.ITEM_SHEET], 24, 160, 8, 8, c.BLACK, 3) rect = self.cursor.image.get_rect() rect.x, rect.y = (220, 358) self.cursor.rect = rect self.cursor.state = c.PLAYER1
def load_frames(self): sheet = settings.GFX[c.ITEM_SHEET] frame_list = [(3, 98, 9, 13), (19, 98, 9, 13), (35, 98, 9, 13), (51, 98, 9, 13)] for frame_rect in frame_list: self.frames.append( game_functions.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
def load_frames(self): sheet = settings.GFX['tile_set'] frame_list = [(384, 0, 16, 16), (400, 0, 16, 16), (416, 0, 16, 16), (400, 0, 16, 16), (432, 0, 16, 16)] for frame_rect in frame_list: self.frames.append( game_functions.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
def load_frames(self): sheet = settings.GFX[c.ITEM_SHEET] frame_list = [(1, 160, 5, 8), (9, 160, 5, 8), (17, 160, 5, 8), (9, 160, 5, 8)] for frame_rect in frame_list: self.frames.append( game_functions.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
def load_frames(self): sheet = settings.GFX[c.ITEM_SHEET] frame_list = [(52, 113, 8, 14), (4, 113, 8, 14), (20, 113, 8, 14), (36, 113, 8, 14)] for frame_rect in frame_list: self.frames.append( game_functions.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
def setup_player(self): self.player_list = [] player_rect_info = [(178, 32, 12, 16), (178, 128, 12, 16)] for rect in player_rect_info: image = game_functions.get_image(settings.GFX['mario_bros'], *rect, c.BLACK, 2.9) rect = image.get_rect() rect.x, rect.bottom = 110, c.GROUND_HEIGHT self.player_list.append((image, rect)) self.player_index = 0
def create_images_dict(self): self.image_dict = {} digit_rect_list = [(1, 168, 3, 8), (5, 168, 3, 8), (8, 168, 4, 8), (0, 0, 0, 0), (12, 168, 4, 8), (16, 168, 5, 8), (0, 0, 0, 0), (0, 0, 0, 0), (20, 168, 4, 8), (0, 0, 0, 0)] digit_string = '0123456789' for digit, image_rect in zip(digit_string, digit_rect_list): self.image_dict[digit] = game_functions.get_image( settings.GFX[c.ITEM_SHEET], *image_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER)
def __init__(self, x, y, sheet, image_rect_list, scale): pygame.sprite.Sprite.__init__(self) self.frames = [] self.frame_index = 0 for image_rect in image_rect_list: self.frames.append(game_functions.get_image(sheet, *image_rect, c.BLACK, scale)) self.image = self.frames[self.frame_index] self.rect = self.image.get_rect() self.rect.x = x self.rect.y = y
def create_font_image_dict(self): self.image_dict = {} image_rect_list = [ # 0 - 9 (3, 230, 7, 7), (12, 230, 7, 7), (19, 230, 7, 7), (27, 230, 7, 7), (35, 230, 7, 7), (43, 230, 7, 7), (51, 230, 7, 7), (59, 230, 7, 7), (67, 230, 7, 7), (75, 230, 7, 7), # A - Z (83, 230, 7, 7), (91, 230, 7, 7), (99, 230, 7, 7), (107, 230, 7, 7), (115, 230, 7, 7), (123, 230, 7, 7), (3, 238, 7, 7), (11, 238, 7, 7), (20, 238, 7, 7), (27, 238, 7, 7), (35, 238, 7, 7), (44, 238, 7, 7), (51, 238, 7, 7), (59, 238, 7, 7), (67, 238, 7, 7), (75, 238, 7, 7), (83, 238, 7, 7), (91, 238, 7, 7), (99, 238, 7, 7), (108, 238, 7, 7), (115, 238, 7, 7), (123, 238, 7, 7), (3, 246, 7, 7), (11, 246, 7, 7), (20, 246, 7, 7), (27, 246, 7, 7), (48, 246, 7, 7), # -* (68, 249, 6, 2), (75, 247, 6, 6) ] character_string = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ -*' for character, image_rect in zip(character_string, image_rect_list): self.image_dict[character] = game_functions.get_image( settings.GFX['text_images'], *image_rect, (92, 148, 252), 2.9)
def setup_background(self): self.background = settings.GFX['level_1'] self.background_rect = self.background.get_rect() self.background = pygame.transform.scale( self.background, (int(self.background_rect.width * c.BACKGROUND_MULTIPLIER), int(self.background_rect.height * c.BACKGROUND_MULTIPLIER))) self.viewport = settings.SCREEN.get_rect( bottom=settings.SCREEN_RECT.bottom) self.image_dict = {} image = game_functions.get_image(settings.GFX['title_screen'], 1, 60, 176, 88, (255, 0, 220), c.SIZE_MULTIPLIER) rect = image.get_rect() rect.x, rect.y = (170, 100) self.image_dict['GAME_NAME_BOX'] = (image, rect)
def load_images(self): sheet = settings.GFX['mario_bros'] frames_list = self.player_data[c.PLAYER_FRAMES] self.right_frames = [] self.left_frames = [] self.right_small_normal_frames = [] self.left_small_normal_frames = [] self.right_big_normal_frames = [] self.left_big_normal_frames = [] for name, frames in frames_list.items(): for frame in frames: image = game_functions.get_image(sheet, frame['x'], frame['y'], frame['width'], frame['height'], c.BLACK, c.SIZE_MULTIPLIER) left_image = pygame.transform.flip(image, True, False) if name == c.RIGHT_SMALL_NORMAL: self.right_small_normal_frames.append(image) self.left_small_normal_frames.append(left_image) elif name == c.RIGHT_BIG_NORMAL: self.right_big_normal_frames.append(image) self.left_big_normal_frames.append(left_image) self.small_normal_frames = [ self.right_small_normal_frames, self.left_small_normal_frames ] self.big_normal_frames = [ self.right_big_normal_frames, self.left_big_normal_frames ] self.all_images = [ self.right_small_normal_frames, self.left_small_normal_frames, self.right_big_normal_frames, self.left_big_normal_frames ] self.right_frames = self.small_normal_frames[0] self.left_frames = self.small_normal_frames[1]
def load_frames(self, sheet, frame_rect_list): for frame_rect in frame_rect_list: self.frames.append( game_functions.get_image(sheet, *frame_rect, c.BLACK, c.SIZE_MULTIPLIER))