View Full Version : Move through an image
05-03-2007, 11:22 AM
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?
05-04-2007, 08:48 PM
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?!
P.S: You will probably want to set a 2D projection using glOrtho and leave Z=0.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.