LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Morgrog on December 17, 2003, 22:58:19

Title: Vertical sync and keyboard input woes
Post by: Morgrog on December 17, 2003, 22:58:19
when I run Nehe's examples (which I'm trying to continue porting to help me learn) with the vertical sync on, the movement (keyboard control) is smooth as it should be.  As soon as I turn it off, the keyboard becomes extra sensitive (the cube spins like a cat on crack).  Could anyone explain to my pea size brain why such a behavior is occuring?
Title: Vertical sync and keyboard input woes
Post by: Numknuf on December 17, 2003, 23:44:46
You're probably using framebased animation: you add a little bit of rotation in degrees for each frame. With vsync the framerate is the same as your monitors refreshrate, maybe 100 Hz. If you turn vsync off opengl tries to do as many frames as possible every second...  :)
Title: Vertical sync and keyboard input woes
Post by: Morgrog on December 18, 2003, 15:24:39
oh, I c, so in order to smooth things out, I need to force the framerate to a certain number?

Is that how games are programmed? I mean, how can u force your game to work at the same speed on different computers?
Title: Vertical sync and keyboard input woes
Post by: Numknuf on December 18, 2003, 15:32:18
Instead of frame based animation you can do time based animation. So instead of rotating 1 degree every frame you do 1 degree every 1/60 of a second.