Running the game
Now you can run the game. You will see the menu shown next if you press Esc:
Figure 19.2: Menu
You will be able to press F1 to quit, as suggested on the menu. However, if you try and press Esc to start, it will also quit the game. This is not the behavior we want. We need to make two quick changes.
We need to delete the temporary code we added to the InputDispatcher.cpp
class back when we first started the project. Locate the following lines of code and delete them:
if (event.type == Event::KeyPressed &&
event.key.code == Keyboard::Escape)
{
m_Window->close();
}
You can now run the game, start and pause with Esc, and quit with F1 when the menu is visible. The InputDispatcher
class no longer handles any events; it just dispatches them to the InputReceiver
instances in the menu, the player, and the mini-map camera.
We also need to stop the game from starting automatically. We do this in the LevelUpdate.h
class.
Find...