from ..actors.buttons import ImageButton
from ..constants import WIDTH, HEIGHT
from ..roaches import big_roaches
-from ..serums import big_serums
+from ..serums import big_serums, SERUMS
from ..vehicles.base import Vehicle
from .base import Scene, ChangeSceneEvent
super().__init__()
self._outside_roach_pos = 0
self._inventory_pos = 0
+ self._inventory_item = None
self._roaches = self.actors.add_layer("roaches", level=10)
- self._serums = self.actors.add_layer("serums", level=10)
+ self._inventory = self.actors.add_layer("inventory", level=10)
self._pads = self.actors.add_layer("pads", level=5)
self._seats = self.actors.add_layer("seats", level=5)
self._buttons = self.actors.add_layer("buttons", level=6)
self._init_pads()
self._init_buttons()
+ self._init_serums()
def enter(self, world):
self._vehicle = Vehicle.by_type(world.vehicles.current)
self._init_bg()
self._init_seats()
self._init_roaches(world.roaches)
- self._update_serums(world.serums)
+ self._update_inventory(world)
def _init_bg(self):
self.actors.default.add(self._vehicle.background)
if i < len(self._seats):
roach_actor.pos = self._seats[i].pos
- def _update_serums(self, serums):
- self._serums.clear()
+ def _init_serums(self):
+ self._serum_actors = {
+ serum: big_serums.assemble(serum) for serum in SERUMS}
+
+ def _update_inventory(self, world):
+ self._inventory.clear()
+ serums = world.serums
if not serums:
return
self._inventory_pos %= len(serums)
- serum_actor = self._serums.add(
- big_serums.assemble(serums[self._inventory_pos]))
+ serum_actor = self._serum_actors[serums[self._inventory_pos]]
inv_pad_centre = self._inventory_pad.center
serum_actor.pos = (
inv_pad_centre[0] + SERUM_OFFSET[0],
inv_pad_centre[1] + SERUM_OFFSET[1])
+ self._inventory.add(serum_actor)
def _init_pads(self):
self._roach_pad = self._pads.add(
print("Eject roach.")
def update(self, world, dt):
- self._update_serums(world.serums)
+ self._update_inventory(world)
def on_key_down(self, key, mod, unicode):
if key == keys.ESCAPE: