Fix anchor for lots roaches
[koperkapel.git] / koperkapel / vehicles / walking.py
1 """ A vehicle to represent roaches on foot. """
2
3 import math
4 from .base import Vehicle, Seat
5 from ..roaches import default_roaches, roaches_quartet, roaches_nonet, WorldRoach
6
7 class Walking(Vehicle):
8
9     vehicle_type = "walking"
10
11     def init_seats(self):
12         n_seats = 6
13         d_theta = 2 * math.pi / n_seats
14         return [
15             Seat(
16                 vehicle=self,
17                 pos=(math.sin(i * d_theta), math.cos(i * d_theta)))
18             for i in range(n_seats)
19         ]
20
21     def get_avatar(self, world):
22         num_roaches = len(world.roaches)
23         roach = WorldRoach()
24         if num_roaches == 1:
25             # Return a single large roach
26             avatar = default_roaches.assemble(roach)
27             avatar.anchor = (0, 0)
28         elif num_roaches < 6:
29             avatar = roaches_quartet.assemble(roach)
30             avatar.anchor = (0, 0)
31         else:
32             avatar = roaches_nonet.assemble(roach)
33             avatar.anchor = (0, 0)
34         return avatar
35
36     def changed(self):
37         return False