| 170 | |
| 171 | |
| 172 | class KeyboardControl(object): |
| 173 | def __init__(self, world): |
| 174 | world.hud.notification("Press 'H' or '?' for help.", seconds=4.0) |
| 175 | |
| 176 | def parse_events(self): |
| 177 | for event in pygame.event.get(): |
| 178 | if event.type == pygame.QUIT: |
| 179 | return True |
| 180 | elif event.type == pygame.KEYUP: |
| 181 | if self._is_quit_shortcut(event.key): |
| 182 | return True |
| 183 | |
| 184 | @staticmethod |
| 185 | def _is_quit_shortcut(key): |
| 186 | return (key == K_ESCAPE) or (key == K_q and pygame.key.get_mods() & KMOD_CTRL) |
| 187 | |
| 188 | # ============================================================================== |
| 189 | # -- HUD ----------------------------------------------------------------------- |