Hacker News new | ask | show | jobs
by wlievens 6682 days ago
Threading is not what you need right where. What you need is called a "game logic loop" (for want of a better term). Keyboard events should change only the "action state" of your game objects and entities, e.g. when you press a key to move left, the player should be in the "moving left" state, but the actual movement should not be handled there.

Parallel to the input (okay you will need a separate thread of keyboard listening and for game logic) you will loop over your entities and update their state, processing things such as movement.