SFML community forums

Help => Graphics => Topic started by: WickedWannabe on July 09, 2018, 09:58:03 pm

Title: Sprite leaving the trail behind on move
Post by: WickedWannabe on July 09, 2018, 09:58:03 pm
Hello good sirs. I have a problem. I'm moving the sprite and as it moves it leaves a lite shade or trail behind as it moves. video (https://youtu.be/cL5oA6YXdVQ)
Heres video, please watch it high quality. You can see the shade on the helmet of character.

Heres the code of main loop
Quote
   sf::Clock clock;
   sf::Time timeSinceLastUpdate = sf::Time::Zero;
   while (isRunning)
   {
      timeSinceLastUpdate += clock.restart();
      while (timeSinceLastUpdate > m_timePerFrame)
      {
         processEvents();
         update(m_timePerFrame);
         render();
         timeSinceLastUpdate -= m_timePerFrame;
      }
   }

And this is the render method
Quote
   m_window->beginDraw();

   m_stateManager->currentState()->render();   

   m_window->endDraw();

Quote
void Window::beginDraw()
{
   m_window.clear();
}

void Window::endDraw()
{
   m_window.display();
}

Quote
void GameLevelState::render()
{
   m_map->draw(m_window);
   m_gameEngine->draw(m_window);
}

m_map drawing map tiles, and gameEngine using render system to draw character.

I tried different things, such as turning on and off framerate limit, vertical sync, moving the render method around the main loop. To use. The trail is still there. Please help. Thanks
Title: Re: Sprite leaving the trail behind on move
Post by: Hapax on July 09, 2018, 11:12:15 pm
I don't understand what is in the video that you don't want to be there.
You say there is a trail but I can only really notice a video compression trail, which I presume is not something that would be present in the original window.
Title: Re: Sprite leaving the trail behind on move
Post by: WickedWannabe on July 09, 2018, 11:20:29 pm
Quote
which I presume is not something that would be present in the original window.
But it is on my game window, exactly as it shows on video. its not a video compression trail. The trail is realy small, but you can see it and sprite slightly jerks as it moves.
Title: Re: Sprite leaving the trail behind on move
Post by: Hapax on July 09, 2018, 11:39:33 pm
Do you mean this:
(https://i.imgur.com/RGkBglp.png)

and sprite slightly jerks as it moves.
This is a topic in itself. Search the forum for things like "timestep", "interpolation", "stutter", "jerky movement" and things like that.
Title: Re: Sprite leaving the trail behind on move
Post by: NGM88 on July 10, 2018, 01:38:26 pm
Make sure the sprite position is always rounded, see if that fixes it.
Title: Re: Sprite leaving the trail behind on move
Post by: WickedWannabe on July 10, 2018, 06:48:15 pm
Alright guys. Thanks alot for help. I changed the code so the sprite position is on closest integer position on a moment of draw call, but the picture is the same. So i changed the monitor and theres totally no trail behind the sprite. Kinda dissapointed in my monitor and ashamed of creation of this post. Anyway thanks again.