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

Method parse_events

PythonAPI/examples/manual_control_rss.py:263–363  ·  view source on GitHub ↗
(self, client, world, clock)

Source from the content-addressed store, hash-verified

261 world.hud.notification("Press 'H' or '?' for help.", seconds=4.0)
262
263 def parse_events(self, client, world, clock):
264 for event in pygame.event.get():
265 if event.type == pygame.QUIT:
266 return True
267 elif event.type == pygame.KEYUP:
268 if self._is_quit_shortcut(event.key):
269 return True
270 elif event.key == K_BACKSPACE:
271 world.restart()
272 elif event.key == K_F1:
273 world.hud.toggle_info()
274 elif event.key == K_h or (event.key == K_SLASH and pygame.key.get_mods() & KMOD_SHIFT):
275 world.hud.help.toggle()
276 elif event.key == K_TAB:
277 world.camera_manager.toggle_camera()
278 elif event.key == K_c and pygame.key.get_mods() & KMOD_SHIFT:
279 world.next_weather(reverse=True)
280 elif event.key == K_c:
281 world.next_weather()
282 elif event.key == K_BACKQUOTE:
283 world.camera_manager.next_sensor()
284 elif event.key > K_0 and event.key <= K_9:
285 world.camera_manager.set_sensor(event.key - 1 - K_0)
286 elif event.key == K_r and not (pygame.key.get_mods() & KMOD_CTRL):
287 world.camera_manager.toggle_recording()
288 elif event.key == K_r and (pygame.key.get_mods() & KMOD_CTRL):
289 if (world.recording_enabled):
290 client.stop_recorder()
291 world.recording_enabled = False
292 world.hud.notification("Recorder is OFF")
293 else:
294 client.start_recorder("manual_recording.rec")
295 world.recording_enabled = True
296 world.hud.notification("Recorder is ON")
297 elif event.key == K_p and (pygame.key.get_mods() & KMOD_CTRL):
298 # stop recorder
299 client.stop_recorder()
300 world.recording_enabled = False
301 # work around to fix camera at start of replaying
302 currentIndex = world.camera_manager.index
303 world.destroy_sensors()
304 # disable autopilot
305 self._autopilot_enabled = False
306 world.player.set_autopilot(self._autopilot_enabled)
307 world.hud.notification("Replaying file 'manual_recording.rec'")
308 # replayer
309 client.replay_file("manual_recording.rec", world.recording_start, 0, 0)
310 world.camera_manager.set_sensor(currentIndex)
311 elif event.key == K_MINUS and (pygame.key.get_mods() & KMOD_CTRL):
312 if pygame.key.get_mods() & KMOD_SHIFT:
313 world.recording_start -= 10
314 else:
315 world.recording_start -= 1
316 world.hud.notification("Recording start time is %d" % (world.recording_start))
317 elif event.key == K_EQUALS and (pygame.key.get_mods() & KMOD_CTRL):
318 if pygame.key.get_mods() & KMOD_SHIFT:
319 world.recording_start += 10
320 else:

Callers 1

game_loopFunction · 0.95

Calls 15

_is_quit_shortcutMethod · 0.95
_parse_vehicle_keysMethod · 0.95
_parse_walker_keysMethod · 0.95
getMethod · 0.45
restartMethod · 0.45
toggle_infoMethod · 0.45
toggleMethod · 0.45
toggle_cameraMethod · 0.45
next_weatherMethod · 0.45
next_sensorMethod · 0.45
set_sensorMethod · 0.45

Tested by

no test coverage detected