""" Base class for vehicles. """
+from itertools import chain, islice, repeat
from pygame.constants import BLEND_RGBA_MULT
from pgzero.actor import Actor
from pgzero.loaders import images
def __init__(self):
self.seats = self.init_seats()
+ self.game_pos = (0, 0)
def roach_management_overlay(self):
return Actor("vehicles/%s/background" % (self.vehicle_type,))
for seat_pos, (roach, _) in roach_seating_numbers if roach
}
+ def seat_roach(self, world, roach, seat_pos):
+ vehicle = world.vehicles[self.vehicle_type]
+ seats = len(self.seats)
+ seating = list(vehicle.seating)
+ seating = list(islice(
+ chain(seating, repeat(None, seats)), 0, seats))
+ seating[seat_pos] = roach
+ # line below records new seating on the world proxy
+ vehicle.seating = seating
+
+ def roach_at(self, world, seat_pos):
+ roach_seating = world.vehicles[self.vehicle_type].seating
+ if seat_pos >= len(roach_seating):
+ return None
+ return roach_seating[seat_pos]
+
_vehicle_types = {}
@classmethod
from .walking import Walking
cls.register(Walking)
+ def get_avatar(self, world):
+ raise NotImplementedError("Vehicles should know how to create their own avatars.")
+
class Seat:
""" A space in a vehicle for a roach.