side scrolling camera following


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

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.

Thanks very much mate.
it works a treat