Skip to main content
GameDev.net gamedev.net
🔒 Locked

Time-Based Loop

Started by Tera Apr 23, 2002 at 12:49 PM 0 replies 400+ views
Original Post
Tera
Tera
Ok... I''ve got a tile engine with a character walking (depending of which arrow you press)... But I want it to walk the same speed with a P3 1000Mhz with a great 3D card and a Pentium 100Mhz without hardware...! I''ve tried QueryPerformanceFreq/Counter but found it strange! Sometimes the delay doesn''t fit with the refresh line of the monitor, so my character is blinking... Oh and by the way I''m usin VB... Anyonye got an idea of what I sould use to have my walk speed always the same? (I guess GetTickCount is the same as QueryPerf things!?!)
Last of The Returners
Palidine
Palidine
for movement use the physics equation:

position = velocity * time + lastPosition;

then use a timing mechanism like getTickCount or timeGetTime to figure out how much time has passed since the last game loop and use that to calculate the new position.

you give everything a velocity and just play around with the speed until it looks like it''s moving at a good rate for you. it''ll move at the same rate on all machines then since the velocity is based on time and not the number of loops that have passed.

for a more detailed answer try using the search function in the forums. this has been discussed up the butt approximately 1000 times before in this very forum.

-me

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.