I have noticed a peculiar problem in my project.
Without VSync, everything seems to work fine.
But when I enable VSync, the movement gets very choppy for some reason.
This is the code I use:
void entity::entity_move( sf::Time * delta )
{
speed = 0.1 * delta->asMicroseconds()/500;
if( moving_left ) position.x -= speed;
if( moving_right ) position.x += speed;
}
void entity::entity_show( sf::RenderWindow * window )
{
entityImage.setPosition( position );
window->draw( entityImage );
}
int main( int argc , char * argv[] )
{
[...]
sf::Clock clock;
sf::Time time;
while( startup::screen_control.window.isOpen() )
{
sf::Event event;
while( startup::screen_control.window.pollEvent( event ) )
{
if( event.type == sf::Event::Closed ) startup::screen_control.window_close();
[...]
}
time = clock.restart();
sprite_1.entity_move( &time );
startup::screen_control.window_clear( sf::Color::Cyan );
sprite_1.entity_show( &startup::screen_control.window );
startup::screen_control.window_display();
}
return 0;
}
What am I doing wrong?