Retrieving peripheral input
A few of the previous chapters have already touched on this subject of retrieving peripheral output a little bit, and, ironically enough, the entire scope of the class was covered. Just to recap, sf::Keyboard is a class that provides a single static method isKeyPressed(sf::Keyboard::Key) to determine the real-time state of a certain keyboard key, which gets passed in as an argument to the method, represented by the sf::Keyboard::Key enumeration table. Because this method is static, sf::Keyboard doesn't need to be instantiated and can be used as follows:
if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)){
// Do something if the W key is pressed.
}This is the way we checked for input in the previous chapters, however, it does lend itself to quite a bit of a mess of if/else statements if we want to check for more keystrokes.
Checking for mouse input
Predictably enough, SFML also provides a class similar to sf::Keyboard with the same idea of obtaining real-time...