VEHICLE_MID_Y = HEIGHT * 1 // 2
BUTTON_INSET = (20, 20)
SERUM_OFFSET = (0, 20)
+ROACH_PAD_OFFSET = (0, 20)
def inset_button(pos, d):
def __init__(self):
super().__init__()
self._vehicle = None
- self._seat_pos = None
+ self._seat_pos = 0
+ self._outside_roach = None
self._outside_roach_pos = 0
self._inventory_pos = 0
self._inventory_item = None
self._init_serums()
def enter(self, world):
- self._vehicle = Vehicle.by_type(world.vehicles.current)
+ self._vehicle = Vehicle.current(world)
self._init_bg()
self._init_seats()
- self._init_roaches(world.roaches)
+ self._init_roaches(world)
self._update_inventory(world)
def _init_bg(self):
seat.vehicle_pos[0] + VEHICLE_MID_X,
seat.vehicle_pos[1] + VEHICLE_MID_Y)
- def _init_roaches(self, roaches):
- self._roach_layer.clear()
- for i, roach in enumerate(roaches):
- roach_actor = self._roach_layer.add(big_roaches.assemble(roach))
- # TODO: less hacky seat assignment
- if i < len(self._seat_layer):
- roach_actor.pos = self._seat_layer[i].pos
+ def _init_roaches(self, world):
+ self._roach_actors = {}
+ for roach in world.roaches:
+ self._roach_actors[roach.name] = big_roaches.assemble(roach)
def _init_serums(self):
self._serum_actors = {
inv_pad_centre[1] + SERUM_OFFSET[1])
self._inventory_layer.add(serum_actor)
+ def _update_roaches(self, world):
+ self._roach_layer.clear()
+ seating = self._vehicle.seating(world)
+ outside_roaches = []
+ for roach in world.roaches:
+ seat_pos = seating.get(roach.name)
+ if seat_pos is not None:
+ roach_actor = self._roach_actors[roach.name]
+ roach_actor.pos = self._seat_layer[seat_pos].pos
+ self._roach_layer.add(roach_actor)
+ else:
+ outside_roaches.append(roach.name)
+ self._outside_roach_pos %= len(outside_roaches)
+ if outside_roaches:
+ roach_actor = self._roach_actors[
+ outside_roaches[self._outside_roach_pos]]
+ roach_pad_center = self._roach_pad.center
+ roach_actor.pos = (
+ roach_pad_center[0] + ROACH_PAD_OFFSET[0],
+ roach_pad_center[1] + ROACH_PAD_OFFSET[1])
+ self._roach_layer.add(roach_actor)
+
def _init_pads(self):
self._roach_pad = self._pad_layer.add(
Actor("roach_management/roach_pad", anchor=("left", "bottom")))
def update(self, world, dt):
self._update_inventory(world)
+ self._update_roaches(world)
def on_key_down(self, key, mod, unicode):
if key == keys.ESCAPE: