(args)
| 991 | |
| 992 | |
| 993 | def 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 | # ============================================================================== |
no test coverage detected