# Item utilities
+from ..serums import default_serums
+
+
+def build_serum(item):
+ actor = default_serums.assemble(item["serum"])
+ return actor
+
+
+ITEM_TYPES = {
+ "serum": build_serum,
+}
+
def get_item(item):
- return item
+ item_type = item.pop("type")
+ game_pos = item.pop("pos")
+ actor = ITEM_TYPES[item_type](item)
+ actor.game_pos = game_pos
+ actor.anchor = (0, 0)
+ return actor
super().enter(world)
self._roaches = self.actors.add_layer("roaches", level=10)
self._friends = self.actors.add_layer("friendly roaches", level=9)
+ self._items = self.actors.add_layer("items", level=9)
self._vehicle = Vehicle.current(world)
self._mode = 'walk'
self._angle = 0
+ self._init_items()
+ self._init_friendly_roaches()
return self._init_roaches(world)
+ def _init_items(self):
+ for item in self._level.items:
+ self._items.add(item)
+
+ def _init_friendly_roaches(self):
+ for friend in self._level.friends:
+ self._friends.add(friend)
+
def _init_roaches(self, world):
x, y = self._level.start_pos
self._level_layer = 'floor'
self._set_pos(x, y)
self._avatar.pos = (WIDTH // 2, HEIGHT // 2)
self._roaches.add(self._avatar)
- for friend in self._level.friends:
- self._friends.add(friend)
# Fix viewport offset
return [
MoveViewportEvent((
for friend in self._friends:
friend.pos = self.calc_offset(
friend.game_pos[0] * TILE_SIZE, friend.game_pos[1] * TILE_SIZE)
+ for item in self._items:
+ item.pos = self.calc_offset(
+ item.game_pos[0] * TILE_SIZE, item.game_pos[1] * TILE_SIZE)
return events
def _movement_key(self, key):