Skip to content

Latest commit

 

History

History
25 lines (18 loc) · 812 Bytes

sprite_move_keyboard_better.rst

File metadata and controls

25 lines (18 loc) · 812 Bytes
orphan

Better Move By Keyboard

Screen shot of moving a sprite by keyboard

If a player presses the left key, the sprite should move left. If the player hits both left and right, the player should stop. If the player lets off the left key, keeping the right key down, the player should move right.

The simpler method of handling keystrokes will not handle this correctly. This code tracks which key is down or up, and handles it properly.

See the highlighted sections.

../../arcade/examples/sprite_move_keyboard_better.py