Consolidation? 0 ▲ ronjeffries.com 122 days ago · Tech · hide · Fediverse post Hello, loves! If we were to combine our formerly three now two sprite lists into one, would we lose some duplicated code? I think we might. Let’s find out. There are two sprite-oriented collections that the Maker and View use: def __init__(self, dungeon): self.setup_assets() self.dungeon = dungeon self.pub_sub = dungeon.pub_sub self.keyed_sprites = KeyedSpriteList(arcade.SpriteList()) self.content_sprites_by_cell: dict[Cell, list[Sprite]] = defaultdict(list) self.setup() The KeyedSpriteList maintains a list of all sprites, which we draw all at once, and a list indexed by cell — or, I think, by content item — used to look up individual sprites. class KeyedSpriteList: def __init__(self, sprite_list): self.sprite_dict = dict() self.sprite_list = sprite_list def add(self, cell, sprite): self.sprite_dict[cell] = sprite self.sprite_list.append(sprite) def draw(self): self.sprite_list.draw() def __getitem__(self, cell): return self.sprite_dict[cell] The content_sprites_by_cell is a… Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town