Jump to content
  • Advertisement


This topic is now archived and is closed to further replies.


Moving an object according to time

This topic is 5324 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi all, my problem is I create a small ball on the screen and I need to move that ball according to some timed event. For example when 5 seconds pass I would like the ball to make a full circle from its current position and the time to do the circle last 0.5 seconds. Right now I can catch the event of when the 5 seconds have passed. But how can I move the ball according to a timer so the full circle is performed in 0.5 seconds? Thanks in advance.

Share this post

Link to post
Share on other sites
If you setup your timer so you know the interval that has passed between two frames then you can use a preset "velocity" value to calculate the amount to move based upon the amount of time which has passed. Your velocity value will be the number of pixels to move each second so the equation to use to find out how much to move by each frame will be:

movement = velocity/(1/secs per frame)

You can simply plug the second part of this directly into your movement code so ballPos += (velocity/(1/FrameTime));

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!