How I would do this is essentially build a duplicate screen that when scrolled to, jumps back to the original. For instance, the top screen can be filled with 25 x 15 BG tiles. If you set BGSCREEN to 50 x 15, you can fill the first half (0-24) with what you want the background to look like and then create a duplicate in the second half (25-49). While using BGOFS to scroll the screen to the right, use a variable to keep track of the "X" position of the screen. Write an IF/THEN statement so that where the "X" would line up with the second half, the program instead resets X back to 0.
How do you loop a background with BGOFS?
Root / Programming Questions / [.]
ResetReloadCreated:
For an example, Google "Flicky longplay". I'm going to attempt to port that game. When Flicky moves, the map does. I can do that with BGOFS but how do you make the map loop indefinately, so you can head in one direction forever?
Of course, to get it to work while scrolling left (continuing the above example), you would just reverse the problem. Whenever you scroll left, you would need to write an IF/THEN statement to have "X" actually jump ahead to behind the duplicate second half.
Essentially, if you are moving to the right "X" will have to jump backwards in order to continue the loop, but if you are moving to the left then "X" will have to jump forwards in order to continue the loop.
You said to make a duplicate screen, would that involve loading your background onto a second layer to help make the transition smooth?
EDIT: For example, I have an ocean background I drew up with three layers that I need to loop since they aren't wide enough to keep scrolling continuously.
Someone did mention dynamically loading them in the chat but I was wondering if there was another recommended solution before I look into what that is and how to use it.
You said to make a duplicate screen, would that involve loading your background onto a second layer to help make the transition smooth?I don't think so. Using the setup I described above, only one layer would be needed.
EDIT: For example, I have an ocean background I drew up with three layers that I need to loop since they aren't wide enough to keep scrolling continuously. Someone did mention dynamically loading them in the chat but I was wondering if there was another recommended solution before I look into what that is and how to use it.Dynamically loading the BG is possible, and it is something that I actually figured out how to do for the game I'm making currently. It is, however, both more difficult to setup and more resource intensive - which means the result probably won't look right on O3DS's. I personally decided to use it because the size of the map I need is too large to fit within the max parameters for BGSCREEN. For your example, I would avoid dynamic loading because I don't think there is a practical reason to do so.
Thanks.
Could explain the method you some of up there some more?
I guess I'm misunderstanding it then since I thought it'd need more than one layer.
Imagine you want a string value to go from "12" to "23" to "34" to "45" to "51" to "12", starting over. You can do this by storing just one string, "123451", and using the pairs of characters: starting at index 0, starting at index 1, at index 2, at index 3, at index 4, and at index 0 again to restart.
In this analogy, the BG is the string "123451", the screen is a pair of characters wide, and BGOFS determines which part of the BG is on the display.
Imagine you want a string value to go from "12" to "23" to "34" to "45" to "51" to "12", starting over. You can do this by storing just one string, "123451", and using the pairs of characters: starting at index 0, starting at index 1, at index 2, at index 3, at index 4, and at index 0 again to restart. In this analogy, the BG is the string "123451", the screen is a pair of characters wide, and BGOFS determines which part of the BG is on the display.You're really clearing things up a bit!I'm still trying to get a good grasp on this though. Since I've loaded my BG into an array, I'd use that like the string in your example, ye? Would I do this with BGLOAD?
You're really clearing things up a bit!I'm still trying to get a good grasp on this though. Since I've loaded my BG into an array, I'd use that like the string in your example, ye? Would I do this with BGLOAD?I think there is either some part of your setup that I don't understand or some misinterpretation of what has been said already, and I'm not sure how to clarify this in a way to make it easier for you to understand. One inconsistency that bothers me, though, is that part of your question includes arrays and BGLOAD (and I assume BGSAVE?), but no explanation given so far needs these things to make continuous BG scrolling to work. So below, I've written in code exactly what I mean to say. With this setup, you should be able to hold the right button and the screen will appear to scroll forever. Edit: If you are using OPTION STRICT, you will need to define variable X.
ACLS BGSCREEN 0,85,15 'the pattern you want repeated BGFILL 0,0,0,19,15,1 BGFILL 0,20,0,39,15,2 BGFILL 0,40,0,59,15,3 'the "duplicate" to create seamless transition BGFILL 0,60,0,79,15,1 BGFILL 0,80,0,84,15,2 'you only need enough to fill up the top screen @LOOP VSYNC 1 IF BUTTON() AND #RIGHT THEN X=X+5 IF X>=960 THEN X=X-960 'when you get to the "duplicated" part, jump back to the beginning BGOFS 0,X,0 GOTO @LOOP
Oh I think I see the communication problem. Well the way I have things set up is I've loaded a layer of the map I've made (using the map editor) to an array using the LOAD command and then used BGLOAD to load it to layer BG layer 0.You're really clearing things up a bit!I'm still trying to get a good grasp on this though. Since I've loaded my BG into an array, I'd use that like the string in your example, ye? Would I do this with BGLOAD?I think there is either some part of your setup that I don't understand or some misinterpretation of what has been said already, and I'm not sure how to clarify this in a way to make it easier for you to understand. One inconsistency that bothers me, though, is that part of your question includes arrays and BGLOAD (and I assume BGSAVE?), but no explanation given so far needs these things to make continuous BG scrolling to work. So below, I've written in code exactly what I mean to say. With this setup, you should be able to hold the right button and the screen will appear to scroll forever. Edit: If you are using OPTION STRICT, you will need to define variable X.ACLS BGSCREEN 0,85,15 'the pattern you want repeated BGFILL 0,0,0,19,15,1 BGFILL 0,20,0,39,15,2 BGFILL 0,40,0,59,15,3 'the "duplicate" to create seamless transition BGFILL 0,60,0,79,15,1 BGFILL 0,80,0,84,15,2 'you only need enough to fill up the top screen @LOOP VSYNC 1 IF BUTTON() AND #RIGHT THEN X=X+5 IF X>=960 THEN X=X-960 'when you get to the "duplicated" part, jump back to the beginning BGOFS 0,X,0 GOTO @LOOP