(args)
| 131 | # ============================================================================== |
| 132 | |
| 133 | def 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 | # ============================================================================== |
no test coverage detected