PDA

View Full Version : Timing?



detzel
05-24-2002, 02:04 PM
I just have a simple ball bouncing but I want to include real physics so to do that i need real timing. Right now I have it moving when it refreshes the scene like 60 times a second but this is bad. I want to make it so I can update the movements like every second but I don't know how to implement something like this, any suggestions would be appreciated.

chowe6685
05-24-2002, 05:18 PM
Look up
GetTickCount()
timeGetTime()
and
QueryPerformanceCounter()

any one of these offers a solution, you'll have to decide which is best for you

nexusone
05-24-2002, 05:43 PM
One way would be to make your movement routine your main loop.

example:


movement()
{
// Movement timming

if (ticks > ball_ticks)
{
update_object();
ball_ticks = ball_ticks + 10; update ball after 10 more seconds.
}

Update_screen();// screen is update even if ball is not moved, this is important if you also are controlling other object.
}


tick_update()
{
// some of this code is made and is to give you an idea on controlling your object. So you will have to replace with correct commands.

time = gettime(); get current time
if (time.second > past_time.second+1) // has a second past between the old time and new time?
{
tick++;
past_time = time;
}
)



Originally posted by detzel:
I just have a simple ball bouncing but I want to include real physics so to do that i need real timing. Right now I have it moving when it refreshes the scene like 60 times a second but this is bad. I want to make it so I can update the movements like every second but I don't know how to implement something like this, any suggestions would be appreciated.