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 2 of 2

Thread: Move through an image

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2007
    Location
    Pelotas, RS, Brazil
    Posts
    4

    Move through an image

    Hello, after drawing an image, I want to move through it, that is, I want to show just some portions of an image and move it.
    This is like an RPG game scenario where the avatar
    moves through it. Only a rectangular part (screen size) of the "world" is show. That is what I want.

    Can you help me?
    Thanks
    "A machine can do the work of fifty ordinary men, but no machine can do
    the work of one extraordinary man.", Shahriar Manzoor

    "All human problems have solution when the men are disposed to solve
    them", Paiva Netto

  2. #2
    Member Regular Contributor
    Join Date
    Dec 2005
    Posts
    256

    Re: Move through an image

    If I understand right what you are trying to do (2D RPG from top view), you should draw your character sprite in the center of the screen and move the map horizontally and vertically.

    In order to do that you have use the command:
    glTranslatef X, Y,Z;
    Where X, Y, and Z are the directions you are translating the object.

    Given keyboard input you should modify X and Y to the opposite direction that the character will move (as character is static in center, moving in the map in the opposite direction causes the desired effect).

    Is that what you wanted to know?!

    Cheers!
    Rod

    P.S: You will probably want to set a 2D projection using glOrtho and leave Z=0.

Posting Permissions

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