1
Graphics / sf::view.zoom() sync with framerate...
« on: May 07, 2012, 06:34:03 am »
Anyone have a suggestion as how to do this? Similar to how you would keep a sprite moving at constistent speed independent of frametime. I'm trying something like this...
This wont quite cut it though. If the framerate is 1000 fps the factor is 1.001 or100.1% of original viewport size.
If it is 60 fps it is 101%.
Since a higher framerate means ZoomOut() gets called more often I was thinking that It would naturally appear to zoom at the same speed but It seems thats not the case.
So basically I'm not sure what kind of math to use here to get a consistent zoom factor across different framerates and my brain is hurting a little bit. Any thoughts?
Code: [Select]
///CAMERA CONTROLS (main app update loop)
if (IsKeyDown[sf::Keyboard::Subtract]) mCamera.ZoomOut();
///Camera Class
Camera::ZoomOut(){
mview.zoom(1 + mApp->GetFrameTime());
}
This wont quite cut it though. If the framerate is 1000 fps the factor is 1.001 or100.1% of original viewport size.
If it is 60 fps it is 101%.
Since a higher framerate means ZoomOut() gets called more often I was thinking that It would naturally appear to zoom at the same speed but It seems thats not the case.
So basically I'm not sure what kind of math to use here to get a consistent zoom factor across different framerates and my brain is hurting a little bit. Any thoughts?