Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Sprite leaving the trail behind on move  (Read 2841 times)

0 Members and 1 Guest are viewing this topic.

WickedWannabe

  • Newbie
  • *
  • Posts: 3
    • View Profile
Sprite leaving the trail behind on move
« 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.
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

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sprite leaving the trail behind on move
« Reply #1 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

WickedWannabe

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Sprite leaving the trail behind on move
« Reply #2 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.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: Sprite leaving the trail behind on move
« Reply #3 on: July 09, 2018, 11:39:33 pm »
Do you mean this:


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.
« Last Edit: July 09, 2018, 11:41:10 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

NGM88

  • Full Member
  • ***
  • Posts: 162
    • View Profile
Re: Sprite leaving the trail behind on move
« Reply #4 on: July 10, 2018, 01:38:26 pm »
Make sure the sprite position is always rounded, see if that fixes it.

WickedWannabe

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Sprite leaving the trail behind on move
« Reply #5 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.

 

anything