FrameRate dependant movement

Started by
26 comments, last by bobason456 18 years, 8 months ago
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
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
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
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.
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
nv/md, found out y that is, b/c i had vsync on (_IMMEDIATE instead of _ONE), but now everything still looks choppy...
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
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.
actually, i am in windowed mode
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
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
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML
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?
-------------------------Unless specified otherwise, my questions pertain:Windows Platform (with the mindset to keep things multi-platform as possible)C++Visual Studio 2008OpenGL with SFML

This topic is closed to new replies.

Advertisement