0

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?

Tomashu
  • 101
  • 3

1 Answers1

-2

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/

  • 1
    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. – Seth Battin Feb 21 '15 at 15:55