June 2013
Beginner to intermediate
296 pages
6h 50m
English
A big part with input management in a game is allowing the user to customize how he interacts with it, like the keys. Most of the time, you can find the most popular key bindings and see them written directly in the code. But there will always be people that want to do stuff their way.
We have to provide tools in order to dynamically bind the keys to specific actions. With the command queue introduced in the previous sections, this becomes a much easier task to accomplish.
With the command queue, we already define specific actions for a specific key. The difference is that right now, we have it hardcoded as follows:
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) commands.push(moveLeft); if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) ...
Read now
Unlock full access