Starting to code the main game loop
As you can see, the last part of the preceding code is the game loop (while (window.isOpen()){}
). We will turn our attention to this now. Specifically, we will be coding the input handling section of the game loop.
The code that we will be adding is quite long. There is nothing complicated about it, though, and we will examine it all in a moment.
Add the following highlighted code to the game loop:
// The main game loop while (window.isOpen()) {     /*     ************     Handle input     ************     */     // Handle events by polling     Event event;     while (window.pollEvent(event))     {         if (event.type == Event::KeyPressed)         {      ...