Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: side scrolling camera following

  1. #1
    Guest

    side scrolling camera following

    hi

    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
    Chris

  2. #2
    Super Moderator OpenGL Guru dorbie's Avatar
    Join Date
    Jul 2000
    Location
    Bay Area, CA, USA
    Posts
    4,388

    Re: side scrolling camera following

    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.

  3. #3
    Guest

    Re: side scrolling camera following

    Thanks very much mate.
    it works a treat

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •