(SDL) Input question
if you don't change:
to
it won't work the way you want it to, as keys[SDLK_SPACE] will return true if the spacebar is down, and from what I understand that's not what you want.
EDIT: slightly made changes to your loop
if(keys[SDLK_SPACE]){addBullet();}
to
if(event.key.keysym.sym == SDLK_SPACE){addBullet();}
it won't work the way you want it to, as keys[SDLK_SPACE] will return true if the spacebar is down, and from what I understand that's not what you want.
EDIT: slightly made changes to your loop
while(done == 0) { SDL_Event event; while ( SDL_PollEvent(&event) ) { if ( event.type == SDL_QUIT ) { done = 1; } if ( event.type == SDL_KEYDOWN ) { if ( event.key.keysym.sym == SDLK_ESCAPE ) { done = 1; } } if(event.type == SDL_KEYUP) { if(event.key.keysym.sym == SDLK_SPACE){addBullet();} } } keys = SDL_GetKeyState(NULL); if ( keys[SDLK_UP] ) { player.accelY(-3); } if ( keys[SDLK_DOWN] ) { player.accelY(3); } if ( keys[SDLK_LEFT] ) { player.accelX(-3); } if ( keys[SDLK_RIGHT] ) { player.accelX(3); } GameLoop(); }
AMP Minibowling - Free asynchronous multiplayer mobile minigolf+bowling
[twitter]eedok[/twitter]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement