1 """ Base class for vehicles. """
3 from pgzero.actor import Actor
7 """ Vehicle base class.
9 A vehicle should have the following attributes:
11 * background -- actor representing background for management scene
12 * seats -- list of roach seats.
16 approximate_radius = 200
19 def by_type(cls, vehicle_type):
20 return cls.vehicle_types.get(vehicle_type)()
23 def register(cls, vehicle_cls):
24 cls.vehicle_types[vehicle_cls.__name__.lower()] = vehicle_cls
27 def register_all(cls):
28 from .walking import Walking
33 """ A space in a vehicle for a roach.
35 * background -- actor representing the seat.
36 * pos -- (x, y) position of the seat relative to the centre of the vehicle.
37 x and y may be numbers from approximately -1.0 to 1.0. They will be
38 multiplied by the approximate_radius of the vehicle.
39 * allowed -- f(roach) for checking whether a roach may occupy the
43 def __init__(self, actor, pos, allowed=None):
46 self.allowed = allowed or (lambda roach: True)
49 Vehicle.register_all()