MCPcopy Create free account
hub / github.com/AdaCompNUS/summit / render_vehicles_ids

Method render_vehicles_ids

PythonAPI/examples/no_rendering_mode.py:305–330  ·  view source on GitHub ↗

When flag enabled, it shows the IDs of the vehicles that are spawned in the world. Depending on the vehicle type, it will render it in different colors

(self, vehicle_id_surface, list_actors, world_to_pixel, hero_actor, hero_transform)

Source from the content-addressed store, hash-verified

303 self._info_text[title] = info
304
305 def render_vehicles_ids(self, vehicle_id_surface, list_actors, world_to_pixel, hero_actor, hero_transform):
306 """When flag enabled, it shows the IDs of the vehicles that are spawned in the world. Depending on the vehicle type,
307 it will render it in different colors"""
308
309 vehicle_id_surface.fill(COLOR_BLACK)
310 if self.show_actor_ids:
311 vehicle_id_surface.set_alpha(150)
312 for actor in list_actors:
313 x, y = world_to_pixel(actor[1].location)
314
315 angle = 0
316 if hero_actor is not None:
317 angle = -hero_transform.rotation.yaw - 90
318
319 color = COLOR_SKY_BLUE_0
320 if int(actor[0].attributes['number_of_wheels']) == 2:
321 color = COLOR_CHOCOLATE_0
322 if actor[0].attributes['role_name'] == 'hero':
323 color = COLOR_CHAMELEON_0
324
325 font_surface = self._header_font.render(str(actor[0].id), True, color)
326 rotated_font_surface = pygame.transform.rotate(font_surface, angle)
327 rect = rotated_font_surface.get_rect(center=(x, y))
328 vehicle_id_surface.blit(rotated_font_surface, rect)
329
330 return vehicle_id_surface
331
332 def render(self, display):
333 """If flag enabled, it renders all the information regarding the left panel of the visualizer"""

Callers 1

renderMethod · 0.80

Calls 2

rotateMethod · 0.80
renderMethod · 0.45

Tested by

no test coverage detected