Jump to content
  • Advertisement
Sign in to follow this  
BloodLust666

FrameRate dependant movement

This topic is 4753 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

What i'm trying to do is keep the framerate as high as it can go but make the movement of my sprites be dependant upon that incase it changes so it doesn't look choppy. What i THOUGHT i would do is" extern float FrameRate; #define FRAMEDELAY (GetTickCount()-FrameDelay>0 ? GetTickCount()-FrameDelay : 1) At the beginning of every frame i do: FrameDelay = GetTickCount(); then when ever i want to move a sprite i multiply the step value times FRAMEDELAY, but sometimes my sprite moves so fast it looks like it does the step value a hundred times in one frame... Am i doing this the wrong way?

Share this post


Link to post
Share on other sites
Advertisement
GetTickCount has a low resolution, i tried on my computer and i could only squeeze a little over 60 updates per second. It says in the documentation that it has milisecond precision, but it doesn't.

You may want to check out a thread i created a while ago about it and high resolution performance counters. Link

Share this post


Link to post
Share on other sites
i don't really understand that... What type is your timeslice, currenttime and all that? you have other members in there like lowdword, what class is that? and can you explain what you're doing in that code?

Share this post


Link to post
Share on other sites
Don't pay too much attention to my pseudocode in the OP, i did some low level arithmetic that confused the code but like someone said in the same thread that was unnecessary.

Check your SDK documentation for QueryPerformanceCounter, QueryFrequencyCounter and LARGE_INTEGER, you should figure out what the types and members are in no time, and should be able to come up with a better solution then the crappy pseudocode in the OP.

Share this post


Link to post
Share on other sites
i got everything to work, instead of using GetTickCount() i'm just calling timeGetTime() and getting the difference from that. But is there a reason y my FPS is topped off at 61 FPS?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yup, vsync. If you're in fullscreen mostly likely your vid card is locked to 60fps max. You'll have to either turn off vsync or switch to windowed mode.

Share this post


Link to post
Share on other sites
is there anything else i'm doing wrong? i'm just tryinbg to get the maximum output of frames (_IMMEDIATE) but still have the movement be dependant on the framerate

Share this post


Link to post
Share on other sites
ok, i have everything running correctly with the frame dependant movement using timeGetTime() but things still look choppy at times... is there any other way or something i'm doing wrong?

Share this post


Link to post
Share on other sites
Sign in to follow this  

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