If key is the same as Game::keys, then if(key[3]) will always run because Game::keys[3] is not zero.
Are you saying if(keypressed[keys[0]]) is also not working? If you are not using SDL_PollEvent in your program you will have to use SDL_PumpEvents(), otherwise the array will not get updated.
But i'm trying to make controls on the game class and just passing the "key" to the player class
like this pseudocode
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
if(keypressed[key[0]]) //witch should be SDL_SCANCODE_W
player->Update(keypressed) //but in this case in the player class i should have
Update(const Uint8 *key) //this can be any key, so i got to specify it in my player class:
{
if(key[SDL_SCANCODE_W]
//doStuff
}
//So i can do this:
if(keypressed[key[0]]) //If SDL_SCANCODE_W
player->Update(key[0]); //meaning SDL_SCANCODE_W
//in witch:
Update(SDL_Scancode key[])
{
if(key[0]) // if is SDL_SCANCODE_W
//doStuff
}