gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Coding > how does wraparound work?

#20758 - Darmstadium - Mon May 17, 2004 3:46 am

I'm working on this demo that has a single 256x256 text background to display the level. My goal: when the player moves either left or right, a new column of tile data is loaded from the array that has the tile data for the level and put it in the screen block that the bg is using. The problem is I don't know how the wraparound feature works. Could someone explain to me excactly how it works? Thanks

#20760 - dagamer34 - Mon May 17, 2004 4:00 am

The wraparound feature works like this:

Basically, text background wrap around. If you were to scroll to x-position 256 at the map, then you would see the entire map begin again.

If you want to load new map tiles dynamically, then you are going to need someway of keep track of your current "world" position as opposed to screen space.

In a nutshell:
Everytime the player moves 8 pixels (1 tile), you would need to load a new column in the direction they are going, and then advance the map forward 8 spaces.

The best way to learn is to analyze some demos that use this feature in VBA.
_________________
Little kids and Playstation 2's don't mix. :(