0
\$\begingroup\$

This question already has an answer here:

I'm trying in my game to have camera rotation speed idependent of fps. For keyboard it works without problems but not for mouse movoment. At 60 fps it works good but at 200 for example rotation is to slow.

mouse_dif is difference since last frame in pixels. Maybe thats a problem too, bigger screen resolution will rotate faster then smaller.

My code:

const float rot_speed = u.GetRotationSpeed(); // returns 5.f
float val = 0;

if(allow_input == ALLOW_INPUT || allow_input == ALLOW_MOUSE)
    val += float(mouse_dif.x)/200;

if(val > rot_speed*dt)
    val = rot_speed*dt;
else if(val < -rot_speed*dt)
    val = -rot_speed*dt;
u.rot += val;

How can I make it fps independent?

\$\endgroup\$

marked as duplicate by Seth Battin, Kromster, Anko, bummzack, congusbongus Mar 2 '15 at 7:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • \$\begingroup\$ Everything is fps independent except camera rotation. \$\endgroup\$ – Tomashu Feb 21 '15 at 21:26
  • 1
    \$\begingroup\$ The concepts are identical for rotation, linear movement, or any other rate that should be time dependent rather than frame dependent. \$\endgroup\$ – Seth Battin Feb 22 '15 at 4:15
-2
\$\begingroup\$

This page has fantastic explanations of different ways to update your game loop, the last one will show you how to make your logic update run independently from updating the screen. Hope it helps: http://www.koonsolo.com/news/dewitters-gameloop/

\$\endgroup\$
  • 1
    \$\begingroup\$ Please avoid avoid link-only answers. Include as much of the content from the remote source as you can to directly answer the question. Of course, attribute the information to the original source. \$\endgroup\$ – Seth Battin Feb 21 '15 at 15:55

Not the answer you're looking for? Browse other questions tagged or ask your own question.