Renders the traffic lights and shows its triggers and bounding boxes if flags are enabled
(self, surface, list_tl, world_to_pixel)
| 1127 | return (vehicles, traffic_lights, speed_limits, walkers) |
| 1128 | |
| 1129 | def _render_traffic_lights(self, surface, list_tl, world_to_pixel): |
| 1130 | """Renders the traffic lights and shows its triggers and bounding boxes if flags are enabled""" |
| 1131 | self.affected_traffic_light = None |
| 1132 | |
| 1133 | for tl in list_tl: |
| 1134 | world_pos = tl.get_location() |
| 1135 | pos = world_to_pixel(world_pos) |
| 1136 | |
| 1137 | if self.args.show_triggers: |
| 1138 | corners = Util.get_bounding_box(tl) |
| 1139 | corners = [world_to_pixel(p) for p in corners] |
| 1140 | pygame.draw.lines(surface, COLOR_BUTTER_1, True, corners, 2) |
| 1141 | |
| 1142 | if self.hero_actor is not None: |
| 1143 | corners = Util.get_bounding_box(tl) |
| 1144 | corners = [world_to_pixel(p) for p in corners] |
| 1145 | tl_t = tl.get_transform() |
| 1146 | |
| 1147 | transformed_tv = tl_t.transform(tl.trigger_volume.location) |
| 1148 | hero_location = self.hero_actor.get_location() |
| 1149 | d = hero_location.distance(transformed_tv) |
| 1150 | s = Util.length(tl.trigger_volume.extent) + Util.length(self.hero_actor.bounding_box.extent) |
| 1151 | if (d <= s): |
| 1152 | # Highlight traffic light |
| 1153 | self.affected_traffic_light = tl |
| 1154 | srf = self.traffic_light_surfaces.surfaces['h'] |
| 1155 | surface.blit(srf, srf.get_rect(center=pos)) |
| 1156 | |
| 1157 | srf = self.traffic_light_surfaces.surfaces[tl.state] |
| 1158 | surface.blit(srf, srf.get_rect(center=pos)) |
| 1159 | |
| 1160 | def _render_speed_limits(self, surface, list_sl, world_to_pixel, world_to_pixel_width): |
| 1161 | """Renders the speed limits by drawing two concentric circles (outer is red and inner white) and a speed limit text""" |
no test coverage detected