Implementing an FPS Camera [solved, thanks irc :D]

I’m trying to implement Lloyd’s FPS camera in my coude but it works very bad, dont know why.
I’ve tried to put the functions that moves the camera into a while (Keyboard.next()) loop but works worst when I do it…
I realy dont know what to do here :S. The game isn’t laggy, works at 60fps :frowning:

here is the source code: http://www.mediafire.com/?da5z2akca1jnnda

the “important” classes are: Game.java and FPCameraController. There’s actually a “InitGL” method into Screen class and I dont know if has the appropiate settings for this setup.

Well, I hope somebody can help me :smiley: Thanks!

What do you mean by looks bad?

thanks for replying

What i mean is that it works bad. So if I press “W” to go forward, it does 1 “step” and then stops, after a few seconds, does another one, and such, while what it has to do is walk forward. If u download the source and run it you will see what I mean. It don’t works smoothly

To detect key presses put this

boolean a = Keyboard.isKeyDown(Keyboard.KEY_A))

Rember to put this within your main game loop

I solved it :slight_smile:

The key was that i got my game loop like:

while (running) {
     clear(); // clear the view and such, move the camera
     render();
}

And the Display.sync method was inside the render() method, so clear() was working in a different fps than the rendering.

Thanks all !!