Getting the input state in real time
Now, we have gone through many varieties of events. A problem with events is that they report once when the state changes, but you cannot continuously ask them how the state of the input devices look right now.
You can solve this by book keeping yourself, which we have done in the examples preceding this chapter. But SFML, in an effort to make input management easier, has implemented classes that let you access these states in real time whenever you want from wherever you want. We will use the notion of real-time input to denote this alternative method of handling user input.
The three classes sf::Joystick
, sf::Keyboard
, and sf::Mouse
can provide almost the same information that the event-based counterparts do, but with some minor variations. They are summarized here and their difference to the events is shown; we recommend visiting the SFML documentation for more details on them. The three classes contain only static functions, so they are not designed...