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

Function game_loop

scenario_runner/no_rendering_mode.py:1376–1416  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

1374
1375
1376def game_loop(args):
1377 try:
1378 # Init Pygame
1379 pygame.init()
1380 display = pygame.display.set_mode(
1381 (args.width, args.height),
1382 pygame.HWSURFACE | pygame.DOUBLEBUF)
1383 pygame.display.set_caption(args.description)
1384
1385 font = pygame.font.Font(pygame.font.get_default_font(), 20)
1386 text_surface = font.render('Rendering map...', True, COLOR_WHITE)
1387 display.blit(text_surface, text_surface.get_rect(center=(args.width / 2, args.height / 2)))
1388 pygame.display.flip()
1389
1390 # Init modules
1391 input_module = ModuleInput(MODULE_INPUT)
1392 hud_module = ModuleHUD(MODULE_HUD, args.width, args.height)
1393 world_module = ModuleWorld(MODULE_WORLD, args, timeout=2.0)
1394
1395 # Register Modules
1396 module_manager.register_module(world_module)
1397 module_manager.register_module(hud_module)
1398 module_manager.register_module(input_module)
1399
1400 module_manager.start_modules()
1401
1402 clock = pygame.time.Clock()
1403 while True:
1404 clock.tick_busy_loop(60)
1405
1406 module_manager.tick(clock)
1407 module_manager.render(display)
1408
1409 pygame.display.flip()
1410
1411 except KeyboardInterrupt:
1412 print('\nCancelled by user. Bye!')
1413
1414 finally:
1415 if world_module is not None:
1416 world_module.destroy()
1417
1418def exit_game():
1419 module_manager.clear_modules()

Callers 1

mainFunction · 0.70

Calls 8

destroyMethod · 0.95
ModuleInputClass · 0.85
ModuleHUDClass · 0.85
ModuleWorldClass · 0.85
register_moduleMethod · 0.80
start_modulesMethod · 0.80
renderMethod · 0.45
tickMethod · 0.45

Tested by

no test coverage detected