#include "Object.h" #include "SDL.h" #include <string> using namespace std; SDL_Event event; Uint8 * keystates = SDL_GetKeyState(NULL); int main(int argc, char *args[] ){ bool quit = false; Object play1; while( quit != true ){ if ( keystates[SDLK_LEFT] == SDL_PRESSED) { play1.xvelocity = 5; } else if ( keystates[SDLK_LEFT] == SDL_RELEASED) { play1.xvelocity = 0; } play1.draw_char(); } return 0; }
When i press key down the player moves for one frame and then stops, and i have to continually keep pressing the key.
I have tried many diff options including the standard SDL_Event. nothing seems to work, when i have a key up event. I can change states fine when there all just key down. PLEASE HELP