Making SDL C++ movement smooth

  c++, game-development, sdl, sdl-2

Hello I’m making a simple break out game in SDL. My problem is I use left and right arrow for moving the bat. But when I press left arrow it moves some pixels and stops.How can I make it move smoothly when I continue pressing the arrow key.Here is my movement code.I have searched for a solution some says I need to use delta time.But I don’t know how to solve this as I’m a beginner.

void HandleEvent()
{
        SDL_Event event;
        if(SDL_PollEvent(&event))
        {
            if(event.type == SDL_QUIT)
            {
                Quit = true;
            }
            else if(event.type ==   SDL_KEYDOWN)
            {
                if(event.key.keysym.sym == SDLK_LEFT && Bat_X >= 0)
                {
                    Bat_X -= 80;
                }
                else if(event.key.keysym.sym == SDLK_RIGHT && Bat_X <= BkW - 60)
                {
                    Bat_X += 80;
                }
            }
        }
}

Source: Windows Questions C++

LEAVE A COMMENT