Receive player input and adjust state.
(session, window, state)
| 610 | |
| 611 | |
| 612 | def move_player(session, window, state): |
| 613 | """Receive player input and adjust state.""" |
| 614 | |
| 615 | ch = window.getch() |
| 616 | if ch not in (LEFT_KEY, RIGHT_KEY, FIRE_KEY, PAUSE_KEY): |
| 617 | return |
| 618 | elif ch == PAUSE_KEY: |
| 619 | pause(session, window, state) |
| 620 | return |
| 621 | |
| 622 | player = state["player"] |
| 623 | if ch == RIGHT_KEY and not player.right_bound: |
| 624 | player.blank(window) |
| 625 | player.x += 1 |
| 626 | elif ch == LEFT_KEY and not player.left_bound: |
| 627 | player.blank(window) |
| 628 | player.x -= 1 |
| 629 | elif ch == FIRE_KEY and state["missile"] is None: |
| 630 | state["missile"] = GlyphCoordinate( |
| 631 | session, "missile", player.x + 3, player.y - 1 |
| 632 | ) |
| 633 | |
| 634 | |
| 635 | def move_missile(session, window, state): |
no test coverage detected