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

Function game_loop

PythonAPI/examples/manual_control.py:993–1027  ·  view source on GitHub ↗
(args)

Source from the content-addressed store, hash-verified

991
992
993def game_loop(args):
994 pygame.init()
995 pygame.font.init()
996 world = None
997
998 try:
999 client = carla.Client(args.host, args.port)
1000 client.set_timeout(2.0)
1001
1002 display = pygame.display.set_mode(
1003 (args.width, args.height),
1004 pygame.HWSURFACE | pygame.DOUBLEBUF)
1005
1006 hud = HUD(args.width, args.height)
1007 world = World(client.get_world(), hud, args)
1008 controller = KeyboardControl(world, args.autopilot)
1009
1010 clock = pygame.time.Clock()
1011 while True:
1012 clock.tick_busy_loop(60)
1013 if controller.parse_events(client, world, clock):
1014 return
1015 world.tick(clock)
1016 world.render(display)
1017 pygame.display.flip()
1018
1019 finally:
1020
1021 if (world and world.recording_enabled):
1022 client.stop_recorder()
1023
1024 if world is not None:
1025 world.destroy()
1026
1027 pygame.quit()
1028
1029
1030# ==============================================================================

Callers 1

mainFunction · 0.70

Calls 9

set_timeoutMethod · 0.95
parse_eventsMethod · 0.95
tickMethod · 0.95
renderMethod · 0.95
destroyMethod · 0.95
HUDClass · 0.70
WorldClass · 0.70
KeyboardControlClass · 0.70
ClientMethod · 0.45

Tested by

no test coverage detected