def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) if sheet is None: return # it's a 32x8 grid of characters char_w = round(sheet.get_width() / 32) char_h = round(sheet.get_height() / 8) for y in range(0, 8): for x in range(0, 32): c = chr(y * 32 + x) grid_cell = [x * char_w, y * char_h, char_w, char_h] true_rect = artutils.find_bounding_rect(grid_cell, sheet, keep_vert=True) if true_rect[2] == 0: self.set_char(c, None) else: true_rect = util.rect_expand(true_rect, right_expand=1) img = sprites.ImageModel(true_rect[0], true_rect[1], true_rect[2], true_rect[3], offset=start_pos) self.set_char(c, img)
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) self._img = sprites.ImageModel(0, 0, sheet.get_width(), sheet.get_height(), offset=start_pos)
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): self.white_boxes.clear() for i in range(0, WhiteSquare._OPACITY_LEVELS): rect = [ start_pos[0] + i * WhiteSquare._SIZE[0], start_pos[1], WhiteSquare._SIZE[0], WhiteSquare._SIZE[1] ] alpha = int(255 * (1 - i / (WhiteSquare._OPACITY_LEVELS - 1))) pygame.draw.rect(atlas, (255, 255, 255, alpha), rect) self.white_boxes.append( sprites.ImageModel(rect[0], rect[1], rect[2], rect[3]))
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) self.player_models = [ sprites.ImageModel(0 + 16 * i, 0, 16, 32, offset=start_pos) for i in range(0, 2) ] self.tv_models = [ sprites.ImageModel(32 + 16 * i, 0, 16, 32, offset=start_pos) for i in range(0, 2) ] self.floor_model = sprites.ImageModel(64, 16, 16, 16, offset=start_pos) self.wall_model = sprites.ImageModel(80, 16, 16, 16, offset=start_pos) self.shadow_model = sprites.ImageModel(64, 0, 16, 16, offset=start_pos) self.border_models = [] for y in range(0, 3): for x in range(0, 3): self.border_models.append( sprites.ImageModel(96 + x * 8, 8 + y * 8, 8, 8, offset=start_pos)) self.all_models = [ self.floor_model, self.wall_model, self.shadow_model ] self.all_models.extend(self.player_models) self.all_models.extend(self.tv_models) self.all_models.extend(self.border_models)
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) if sheet is None: return # it's a 32x8 grid of characters char_w = round(sheet.get_width() / 32) char_h = round(sheet.get_height() / 8) for y in range(0, 8): for x in range(0, 32): c = chr(y * 32 + x) self._sprite_lookup[c] = sprites.ImageModel(x * char_w, y * char_h, char_w, char_h, offset=start_pos)
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) if sheet is None: return # it's a 32x8 grid of characters char_w = round(sheet.get_width() / 32) char_h = round(sheet.get_height() / 8) for y in range(0, 8): for x in range(0, 32): c = chr(y * 32 + x) rect = [x * char_w, y * char_h, char_w, char_h] rect = self.xform_char_rect(rect, sheet) if rect is None or rect[2] == 0: self.set_char(c, None) else: self.set_char( c, sprites.ImageModel(rect[0], rect[1], rect[2], rect[3], offset=start_pos))
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): w, h = self.get_size((0, 0)) rect = [start_pos[0], start_pos[1], w, h] pygame.draw.rect(atlas, (255, 255, 255), rect) self.white_box = sprites.ImageModel(0, 0, w, h, offset=start_pos)
def draw_to_atlas(self, atlas, sheet, start_pos=(0, 0)): super().draw_to_atlas(atlas, sheet, start_pos=start_pos) self.ui_panel_bg = sprites.ImageModel(0, 0, 112, 300, offset=start_pos) self.ui_blight_bar_bg = sprites.ImageModel(128, 224, 288, 16, offset=start_pos) self.ui_blight_bar = sprites.ImageModel(176, 240, 16, 16, offset=start_pos) self.giant_rock = sprites.ImageModel(0, 320, 320, 208, offset=start_pos) self.fruit_icons = [ sprites.ImageModel(128 + i * 16, 0, 16, 16, offset=start_pos) for i in range(0, 3) ] self.veg_icons = [ sprites.ImageModel(128 + i * 16, 16, 16, 16, offset=start_pos) for i in range(0, 3) ] self.mushroom_icons = [ sprites.ImageModel(128 + i * 16, 32, 16, 16, offset=start_pos) for i in range(0, 3) ] self.flower_icons = [ sprites.ImageModel(128 + i * 16, 48, 16, 16, offset=start_pos) for i in range(0, 3) ] self.shovel_icon = sprites.ImageModel(176, 0, 16, 16, offset=start_pos) self.growing_rock_icon = sprites.ImageModel(176, 16, 16, 16, offset=start_pos) self.tombstone_icon = sprites.ImageModel(176, 32, 16, 16, offset=start_pos) self.storage_bin_icon = sprites.ImageModel(176, 48, 16, 16, offset=start_pos) self.icon_outline = sprites.ImageModel(208, 16, 16, 16, offset=start_pos) self.no_icon = sprites.ImageModel(208, 32, 16, 16, offset=start_pos) self.yes_icon = sprites.ImageModel(224, 32, 16, 16, offset=start_pos) self.question_icon = sprites.ImageModel(208, 48, 16, 16, offset=start_pos) self.next_day_button = sprites.ImageModel(128, 80, 68, 16, offset=start_pos) self.next_day_outline = sprites.ImageModel(128, 96, 68, 16, offset=start_pos) self.tile_empty = sprites.ImageModel(208, 80, 16, 16, offset=start_pos) self.tile_dirt = sprites.ImageModel(224, 80, 16, 16, offset=start_pos) self.blight_icons = [ sprites.ImageModel(240, 80 + i * 16, 16, 16, offset=start_pos) for i in range(0, 3) ] self.vp_symbol = sprites.ImageModel(272, 80, 17, 9, offset=start_pos) self.money_symbol = sprites.ImageModel(272, 96, 12, 13, offset=start_pos) self.fruit_symbol = sprites.ImageModel(304, 80, 8, 8, offset=start_pos) self.veg_symbol = sprites.ImageModel(312, 80, 8, 8, offset=start_pos) self.mushroom_symbol = sprites.ImageModel(320, 80, 8, 8, offset=start_pos) self.flower_symbol = sprites.ImageModel(328, 80, 8, 8, offset=start_pos) self.blight_symbol = sprites.ImageModel(336, 80, 8, 8, offset=start_pos) self.contract_panels = [ sprites.ImageModel(128 + i * 80, 128, 80, 69, offset=start_pos) for i in range(0, 4) ] self.contract_panel_fruit = self.contract_panels[0] self.contract_panel_veg = self.contract_panels[1] self.contract_panel_mushroom = self.contract_panels[2] self.contract_panel_flower = self.contract_panels[3] self.contract_panel_bar = sprites.ImageModel(128, 208, 16, 2, offset=start_pos) self.contract_panel_bar_endcap = sprites.ImageModel( 144, 208, 1, 2, offset=start_pos) # not used self.box_borders = [ sprites.ImageModel(120 + (i % 3) * 8, 248 + (i // 3) * 8, 8, 8, offset=start_pos) for i in range(0, 9) ]