1
General / Re: How do I move an object once every a constant time interval
« on: April 02, 2018, 07:44:15 pm »You can create an sf::Clock and check the elapsed time every frame. And after it reaches the timer threshold you want, you move your player quad and reset the clock.
Example code:sf::RectangleShape player(sf::Vector2f(100.f,100.f));
sf::Clock timer;
//in the game loop
if (timer.getElapsedTime().asMilliseconds() >= 500)
{
player.move(0, 5); // replace 5 with anything you want
timer.restart();
}
Cheers mate