Jump to content
• Advertisement

Public Group

#### Archived

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

##### Share on other sites
Advertisement
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

##### Share on other sites
is that the same as
movement = velocity * secs per frame
?

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 11
• 10
• 13
• 98
• 11
• ### Forum Statistics

• Total Topics
632974
• Total Posts
3009654
• ### Who's Online (See full list)

There are no registered users currently online

×

## 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!