for some reason my keystates isnt working, i could make this work using "sdl_pollevent" but i would like it so that as long as user is holding the down key my function runs. I am doing this to make a paddle in my pong game go down, or if there is a better way to handle continuous inut, plz tell me how.
Help would be gratly appreciated
thanks
SDL_GetKeyState returns the same array every time so it doesn't matter if you call it inside or outside the loop.
zacaj is right. Normally when you use SDL_PollEvent or SDL_WaitEvent you don't need to call SDL_PumpEvents because these functions calls SDL_PumpEvents on their own. Here it is needed or otherwise the key state will never update.
SDL_GetKeyState returns the same array every time so it doesn't matter if you call it inside or outside the loop.
zacaj is right. Normally when you use SDL_PollEvent or SDL_WaitEvent you don't need to call SDL_PumpEvents because these functions calls SDL_PumpEvents on their own. Here it is needed or otherwise the key state will never update.
Thanks for the reply guys, can you tell me how to use Pump event or give me a link explaining it, because i cant seem to find a decent tutorial on it
Thank you guys so much, i finally got my paddle working, what i did was i put SDL_Pumpevents as soon as the loop starts and then inside i have my if statements. Thanks again
You'll need to consume events from the event queue or the OS may assume your application is unresponsive. At the very least, you'll want to be processing SDL_QUIT events too.