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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - chrisamgad

Pages: [1]
1
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 ;)

2
General / How do I move an object once every a constant time interval
« on: April 02, 2018, 06:34:39 pm »
for example I have
sf::RectangleShape player(sf::Vector2f(100.f,100.f))

How do I make the player move once like every 500 milliseconds upwards for example?

Pages: [1]