View Full Version : side scrolling camera following

03-10-2004, 09:28 AM
hi http://www.opengl.org/discussion_boards/ubb/smile.gif

i am making a 2d side scrolling platform game with the camera following the character while the platforms and obstacles move in relation to the character and camera.

I have been trying to use gluLookAt and gluPerspective but have had no luck with them.

Can some1 please give me some advice on the best way to make the camera follow the character.

Many thanks

03-10-2004, 08:43 PM
Once you get things rendering correctly, use a glTranslate call on the modelview matrix before you draw the scene with the character.

glTranslate2f(-charpos_x, -charpos_y, 0.0);

As you can see this will conteract the character's translate and so the eye will track with the character.

You could just use the translate in the x axis to track the character horizontally and allow the character to move vertically on the screen depending on your level design.

03-11-2004, 02:27 AM
Thanks very much mate.
it works a treat http://www.opengl.org/discussion_boards/ubb/smile.gif