I am following a tutorial. The author has choosen a structure for handling keyboards inputs which i do not really understand.
This is the section for keyboard input.
A. Loop
while (window.pollEvent(event))
e.g. if (event.key.code == Keyboard::Return && state == State::PLAYING) state = State::PAUSED;
B. Realtime input
e.g. if (Keyboard::isKeyPressed(Keyboard::W)) player.moveUp();
C. Special Game State input
e.g. if (event.key.code = Keyboard::Num1) state = State::PLAYING; // No loop
I struggle to understand part C. Every time a key is pressed, event is created and added to a queue. Part A loops through the queue and removes any event. So which event is used by part C ? It is already in a new queue and what happens when there are several new events already in the queue ? Does event.key.code always point to the next event which should leave the queue ?
Thanks for help ?