How to implement "circular side-scrolling" in my game?
I'm developing a game, a big part of this game, is about scrolling a "circular" background ( the right end of the Background Image can connect with the left start of the Background image ).
Should be something like this: ( Entity moving and arrow to show where the background should start to repeat )
alt text http://img89.imageshack.us/img89/9308/circular.jpg
This happens in order to allow to have an Entity walking, and the background repeating itself over and over again.
I'm not working with tile-maps, the b开发者_运维百科ackground is a simple Texture (400x300 px).
Could anyone point me to a link , or tell me the best way I could accomplish this ?
Thanks a lot.
Alternatively you can translate the texture using an appropriate texture matrix. This saves you from having to recalculate/upload your UV coordinates each frame.
I don't know how different it is on the iPhone (OpenGL ES, I believe?), but in normal OpenGL, you'd set the texture tiling to repeat and then simply change the UV coordinates by the distance that the player moved. The texture tiling is set using:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
精彩评论