My problem is if i press a button to move the image doesnt go away. It leaves like a trail. Also, how do i make it so that if i hold down the button it will keep going. here is my code
To prevent "trails" from appearing, you would clear the scene every time you draw:
1 2 3 4 5 6 7 8 9
void DrawScene()
{
ClearTheScreen(); // I forget the SDL function for this, but basically you wipe it to black
// or whatever BG color you want
DrawAllObjects();
SDL_Flip();
}
Well if you've had a key down event about a particular key but not a key up event about that same key since the last key down event, you know that the key in question is currently held down. So you'll need to store a list of keys and whether they are up or down, then when you get a key up or key down event set that key's value, and every loop check whether or not a key is currently down.