MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / move_player

Function move_player

examples/space_invaders/space_invaders.py:612–632  ·  view source on GitHub ↗

Receive player input and adjust state.

(session, window, state)

Source from the content-addressed store, hash-verified

610
611
612def 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
635def move_missile(session, window, state):

Callers 1

update_stateFunction · 0.85

Calls 3

pauseFunction · 0.85
GlyphCoordinateClass · 0.85
blankMethod · 0.80

Tested by

no test coverage detected