![]() |
Issues with Keyboard Events | ![]() |
![]() |
![]() |
Christian Knudsen
![]() |
![]() |
On a quick glance you should have
instead of 'if', since 'if' will only handle the first event on the queue. |
||||||||||||
|
![]() |
![]() |
Naith
![]() |
![]() |
One thing to note, besides what Christian has written, is to always break out of every switch case, to avoid weird bugs in the switch block. So add 'break;' after/under 'cout << "w was pressed" << endl;' in the SDLK_w case.
Also, if you don't wanna write 'if(Event.type ==' all the time, you can change the Event.type into a switch case aswell. The fixed event code would then look like this:
|
||||||||||||
|
![]() |
![]() |
104809
![]() |
![]() |
Thanks guys. I didn`t know it should be while(SDL_PollEvent(&Event)).The "if's" are only there for simplification, later on i will go with switch().
But the Problem is still there, Keypressed will only get noticed after several presses, or by holding the button down. I am out of ideas and can`t find the problem. |
||||||||||
|
![]() |
![]() |
104809
![]() |
![]() |
I found the Problem, another Function in the Run() Function was written bad and slowed everything down.
|
||||||||||
|