0
\$\begingroup\$

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\$
2
  • \$\begingroup\$ Everything is fps independent except camera rotation. \$\endgroup\$
    – Tomashu
    Commented Feb 21, 2015 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\$ Commented Feb 22, 2015 at 4:15

1 Answer 1

-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
  • 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\$ Commented Feb 21, 2015 at 15:55

Not the answer you're looking for? Browse other questions tagged .