#27805 - mr_square - Thu Oct 21, 2004 4:35 pm
Hi all. I've implemented a tile strip copying method into my code that lets me scroll around any size map, with just 256x256 actually stored on the GBA. The horizontal scroll works fine by itself, the vertical scroll works fine by itself, but combining them together to do a diagonal scroll just produces a mess.
The method itself is fairly large, but most of it is just spent calculating which tile strip is due to be replaced. The key lines are:
My viewing window shows a portion of the overall map that is xoffset across it and yoffset down it. The first loop is the horizontal scroller. It copies a vertical strip of offscreen tiles into the mapData area - these are then shown when the background wraps around. The other one copies horizontal strips to produce a vertical scroll.
Combining them both like that obviously isnt the way to scroll diagonally, but I'm not quite sure how else it should be done :(. Any help would be much appreciated - let me know if you need any furthur info on the method.
The method itself is fairly large, but most of it is just spent calculating which tile strip is due to be replaced. The key lines are:
Code: |
//......Code to choose tile strip to replace......// //Vertical strip copier for(yloop = 0; yloop < 32; yloop++) { mapData[(32*yloop)+ currentVStrip] = map[((yoffset + yloop)* mapWidth) + (xValue)]; } //Horizontal strip copier for(xloop = 0; xloop < 32; xloop++) { mapData[(32*currentHStrip)+ xloop] = map[((yValue)* mapWidth) + (xoffset + xloop)]; } //.......Code to scroll map and update offsets........// |
My viewing window shows a portion of the overall map that is xoffset across it and yoffset down it. The first loop is the horizontal scroller. It copies a vertical strip of offscreen tiles into the mapData area - these are then shown when the background wraps around. The other one copies horizontal strips to produce a vertical scroll.
Combining them both like that obviously isnt the way to scroll diagonally, but I'm not quite sure how else it should be done :(. Any help would be much appreciated - let me know if you need any furthur info on the method.