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

Method render

PythonAPI/examples/no_rendering_mode.py:1274–1357  ·  view source on GitHub ↗

Renders the map and all the actors in hero and map mode

(self, display)

Source from the content-addressed store, hash-verified

1272 self.map_image.scale_map(scale_factor)
1273
1274 def render(self, display):
1275 """Renders the map and all the actors in hero and map mode"""
1276 if self.actors_with_transforms is None:
1277 return
1278 self.result_surface.fill(COLOR_BLACK)
1279
1280 # Split the actors by vehicle type id
1281 vehicles, traffic_lights, speed_limits, walkers = self._split_actors()
1282
1283 # Zoom in and out
1284 scale_factor = self._input.wheel_offset
1285 self.scaled_size = int(self.map_image.width * scale_factor)
1286 if self.scaled_size != self.prev_scaled_size:
1287 self._compute_scale(scale_factor)
1288
1289 # Render Actors
1290 self.actors_surface.fill(COLOR_BLACK)
1291 self.render_actors(
1292 self.actors_surface,
1293 vehicles,
1294 traffic_lights,
1295 speed_limits,
1296 walkers)
1297
1298 # Render Ids
1299 self._hud.render_vehicles_ids(self.vehicle_id_surface, vehicles,
1300 self.map_image.world_to_pixel, self.hero_actor, self.hero_transform)
1301 # Show nearby actors from hero mode
1302 self._show_nearby_vehicles(vehicles)
1303
1304 # Blit surfaces
1305 surfaces = ((self.map_image.surface, (0, 0)),
1306 (self.actors_surface, (0, 0)),
1307 (self.vehicle_id_surface, (0, 0)),
1308 )
1309
1310 angle = 0.0 if self.hero_actor is None else self.hero_transform.rotation.yaw + 90.0
1311 self.traffic_light_surfaces.rotozoom(-angle, self.map_image.scale)
1312
1313 center_offset = (0, 0)
1314 if self.hero_actor is not None:
1315 # Hero Mode
1316 hero_location_screen = self.map_image.world_to_pixel(self.hero_transform.location)
1317 hero_front = self.hero_transform.get_forward_vector()
1318 translation_offset = (hero_location_screen[0] - self.hero_surface.get_width() / 2 + hero_front.x * PIXELS_AHEAD_VEHICLE,
1319 (hero_location_screen[1] - self.hero_surface.get_height() / 2 + hero_front.y * PIXELS_AHEAD_VEHICLE))
1320
1321 # Apply clipping rect
1322 clipping_rect = pygame.Rect(translation_offset[0],
1323 translation_offset[1],
1324 self.hero_surface.get_width(),
1325 self.hero_surface.get_height())
1326 self.clip_surfaces(clipping_rect)
1327
1328 Util.blits(self.result_surface, surfaces)
1329
1330 self.border_round_surface.set_clip(clipping_rect)
1331

Callers 1

game_loopFunction · 0.95

Calls 10

_split_actorsMethod · 0.95
_compute_scaleMethod · 0.95
render_actorsMethod · 0.95
_show_nearby_vehiclesMethod · 0.95
clip_surfacesMethod · 0.95
absFunction · 0.85
render_vehicles_idsMethod · 0.80
rotozoomMethod · 0.80
world_to_pixelMethod · 0.80
blitsMethod · 0.80

Tested by

no test coverage detected