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

Method _parse_keys

PythonAPI/examples/no_rendering_mode.py:1459–1473  ·  view source on GitHub ↗

Parses keyboard input when keys are pressed

(self, milliseconds)

Source from the content-addressed store, hash-verified

1457 self.wheel_offset = 0.1
1458
1459 def _parse_keys(self, milliseconds):
1460 """Parses keyboard input when keys are pressed"""
1461 keys = pygame.key.get_pressed()
1462 self.control.throttle = 1.0 if keys[K_UP] or keys[K_w] else 0.0
1463 steer_increment = 5e-4 * milliseconds
1464 if keys[K_LEFT] or keys[K_a]:
1465 self._steer_cache -= steer_increment
1466 elif keys[K_RIGHT] or keys[K_d]:
1467 self._steer_cache += steer_increment
1468 else:
1469 self._steer_cache = 0.0
1470 self._steer_cache = min(0.7, max(-0.7, self._steer_cache))
1471 self.control.steer = round(self._steer_cache, 1)
1472 self.control.brake = 1.0 if keys[K_DOWN] or keys[K_s] else 0.0
1473 self.control.hand_brake = keys[K_SPACE]
1474
1475 def _parse_mouse(self):
1476 """Parses mouse input"""

Callers 1

parse_inputMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected