MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / game_loop

Function game_loop

scenario_runner/manual_control.py:133–168  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

131# ==============================================================================
132
133def game_loop(args):
134 pygame.init()
135 pygame.font.init()
136 world = None
137
138 try:
139 client = carla.Client(args.host, args.port)
140 client.set_timeout(2.0)
141
142 display = pygame.display.set_mode(
143 (args.width, args.height),
144 pygame.HWSURFACE | pygame.DOUBLEBUF)
145
146 hud = HUD(args.width, args.height)
147 world = WorldSR(client.get_world(), hud, args)
148 controller = KeyboardControl(world, args.autopilot)
149
150 clock = pygame.time.Clock()
151 while True:
152 clock.tick_busy_loop(60)
153 if controller.parse_events(client, world, clock):
154 return
155 if not world.tick(clock):
156 return
157 world.render(display)
158 pygame.display.flip()
159
160 finally:
161
162 if (world and world.recording_enabled):
163 client.stop_recorder()
164
165 if world is not None:
166 world.destroy()
167
168 pygame.quit()
169
170
171# ==============================================================================

Callers 1

mainFunction · 0.70

Calls 7

parse_eventsMethod · 0.95
tickMethod · 0.95
WorldSRClass · 0.85
get_worldMethod · 0.80
KeyboardControlClass · 0.50
renderMethod · 0.45
destroyMethod · 0.45

Tested by

no test coverage detected