How to implement the "circular scroll" in my game?

I am developing a game, most of this game is scrolling a “circular” background (the right end of the background image can connect to the left beginning of the background image).

There should be something like this: (Entity movement and arrow to show where the background should start repeating)

alt text http://img89.imageshack.us/img89/9308/circular.jpg

This happens to allow Entity to walk, and the background repeats over and over.

I do not work with card tiles, the background is a simple texture (400x300 pixels).

Can someone point me a link or tell me how I could do this?

Many thanks.

+4
source share
2 answers

Alternatively, you can translate the texture using a texture matrix . This saves you from having to recalculate / upload the UV coordinates of each frame.

+2
source

I don’t know how different this is from the iPhone (OpenGL ES, I believe?), But in regular OpenGL you have to repeat the repetition of the texture tile and then just change the UV coordinates to the distance the player has moved. Texture filtering is set using:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); 
+2
source

Source: https://habr.com/ru/post/1307251/


All Articles