-2
\$\begingroup\$
Uint32 StartTicks;
int FrameTime;
const int FrameDelay = 1000 / 60;
while (Window::GetInstance()->GetGameStatus())
{
    StartTicks = SDL_GetTicks();

    Renderer::GetInstance()->ClearScreen();

    mWorld.Render();
    //FarmingUtils::GetInstance()->RenderPaddyLand();
    mPlayer.Render();

    EventHandler::GetInstance()->PollEvents();
    if (EventHandler::GetInstance()->HasEventOccured(EVENT::WINDOW_CLOSE) || EventHandler::GetInstance()->IsKeyPressed(SDL_SCANCODE_ESCAPE))
        Window::GetInstance()->SetGameStatus(false);
    else if (EventHandler::GetInstance()->HasEventOccured(EVENT::WINDOW_RESIZE))
        Camera::GetInstance()->SetNewCoordinates();


    Renderer::GetInstance()->DrawScreen();

    FrameTime = SDL_GetTicks() - StartTicks;
    if (FrameDelay > FrameTime)
        SDL_Delay(FrameDelay - FrameTime);
}

SDL2 Screen flickering, update loop is running in another thread, Screen flickers when the player goes down completely then comes up, it's kind of in mid way.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.