Removable
By Chris Proctor
- class quest.contrib.removable.RemovableMixin[source]
A mixin for QuestGame which adds support for removing sprites from the game.
When a sprite is removed, it no longer shows up on the game map. This could already be achieved using sprite.kill(), but sometimes you want to keep track of a sprite even though it has been removed: perhaps it will return, or perhaps it has gone somewhere like into the player’s inventory.
The key to this mixin is that QuestGame only renders and checks for collisions on certain SpriteLists, such as self.wall_list and self.npc_list. So when we remove a sprite from one of these “live” SpriteLists, it will no longer show up or trigger collisions.
RemovableMixin extends initialization to add a dictionary called removed_sprite_lists, where each key is the name of a list in which to store removed sprites. If you don’t need more than one place to store removed sprites, you can ignore this; they will all be stored in “default.”
- removed_sprite_list_names
A list of strings naming destinations for removed sprites. By default, there is just one destination, called “default,” but you might want others like “inventory” or “shop” or “dead_spirits_seeking_revenge.”