Hello,
I have been programming with c++ and SDL 2.
I have run into a problem where I want multiple keys input to be read at once but it will only use one key at a time and stop the instructions for each key after another has been hit even though it is still being pressed. (for example using the W key and the A key to move diagonally). Here is part of the code
/*switch(e.key.keysym.sym)
{
case SDLK_s:
position.y += vely;
break;
case SDLK_a:
position.x -= velx;
break;
case SDLK_d:
position.x += velx;
break;
case SDLK_w:
position.y -= vely;
break;
default:
break;
}
//here is a second try:
if(e.key.keysym.sym == SDLK_w )
{
position.y -= vely;
if ( e.key.keysym.sym == SDLK_a )
{
position.y -= vely;
position.x -= velx;
}
It will interrupt the past input and will not accept two key values but only one. when I hit another key it will stop the past inputs instructions even though it is still being presses. I know this issue is probably very noobish but any help would be greatly appreciated.
Thank you for your time.