(args)
| 869 | |
| 870 | |
| 871 | def game_loop(args): |
| 872 | pygame.init() |
| 873 | pygame.font.init() |
| 874 | world = None |
| 875 | |
| 876 | try: |
| 877 | client = carla.Client(args.host, args.port) |
| 878 | client.set_timeout(2.0) |
| 879 | |
| 880 | display = pygame.display.set_mode( |
| 881 | (args.width, args.height), |
| 882 | pygame.HWSURFACE | pygame.DOUBLEBUF) |
| 883 | |
| 884 | hud = HUD(args.width, args.height) |
| 885 | world = World(client.get_world(), hud, args.filter, args.rolename) |
| 886 | controller = KeyboardControl(world, args) |
| 887 | |
| 888 | clock = pygame.time.Clock() |
| 889 | while True: |
| 890 | clock.tick_busy_loop(60) |
| 891 | if controller.parse_events(client, world, clock): |
| 892 | return |
| 893 | world.tick(clock) |
| 894 | world.render(display) |
| 895 | pygame.display.flip() |
| 896 | |
| 897 | finally: |
| 898 | |
| 899 | if (world and world.recording_enabled): |
| 900 | client.stop_recorder() |
| 901 | |
| 902 | if world is not None: |
| 903 | world.destroy() |
| 904 | |
| 905 | pygame.quit() |
| 906 | |
| 907 | |
| 908 | # ============================================================================== |
no test coverage detected