It is great that we are able to add shapes, sprites, and textures; however, computer games, by nature, are interactive. We will need to allow players to use keyboard inputs so that they can access the game's content. But how do we know which button the player is pressing? Well, that is handled through the polling of events. Polling just checks the status of the keys regularly; events are used to check whether an event was triggered, such as the closing of the viewport.
SFML provides the sf::Event class so that we can poll events. We can use the pollEvent function of the window to check for events that may be occurring, such as a player pressing a button.
Create a new function called updateInput(). Here, we will create a new object of the sf::Event class called event. We will create a while loop called window.pollEvent and then pass in the event variable to...