def load_frames(self): sheet = setup.GFX[c.ITEM_SHEET] frame_rect_list = [(0, 0, 32, 32), (32, 0, 32, 32), (64, 0, 32, 32), (96, 0, 32, 32)] for frame_rect in frame_rect_list: self.frames.append(tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
def setup_cursor(self): self.cursor = pg.sprite.Sprite() self.cursor.image = tools.get_image(setup.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 create_player_image(self): if self.game_info[c.PLAYER_NAME] == c.PLAYER_MARIO: rect = (178, 32, 12, 16) else: rect = (178, 128, 12, 16) self.player_image = tools.get_image(setup.GFX['icon'], *rect, (0, 0, 32), 2.9) self.player_rect = self.player_image.get_rect(center=(320, 290))
def load_frames(self): ### Get Box tile From Image Source sheet = setup.GFX['image'] frame_rect_list = [(436, 32, 32, 32), (436, 32, 32, 32), (436, 32, 32, 32), (436, 32, 32, 32), (436, 32, 32, 32)] for frame_rect in frame_rect_list: self.frames.append( tools.get_image(sheet, *frame_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER))
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] = tools.get_image(setup.GFX[c.ITEM_SHEET], *image_rect, c.BLACK, c.BRICK_SIZE_MULTIPLIER)
def __init__(self, x, y, sheet, image_rect_list, scale): pg.sprite.Sprite.__init__(self) self.frames = [] self.frame_index = 0 for image_rect in image_rect_list: self.frames.append( tools.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_list = [] 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] = tools.get_image( setup.GFX['text_images'], *image_rect, (92, 148, 252), 2.9)
def load_images(self): sheet = setup.GFX['player'] 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 = [] self.right_big_fire_frames = [] self.left_big_fire_frames = [] for name, frames in frames_list.items(): for frame in frames: image = tools.get_image(sheet, frame['x'], frame['y'], frame['width'], frame['height'], c.BLACK, c.SIZE_MULTIPLIER) left_image = pg.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) elif name == c.RIGHT_BIG_FIRE: self.right_big_fire_frames.append(image) self.left_big_fire_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.big_fire_frames = [ self.right_big_fire_frames, self.left_big_fire_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_big_fire_frames, self.left_big_fire_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(tools.get_image(sheet, *frame_rect, c.BLACK, c.SIZE_MULTIPLIER))