LoginLogin
Nintendo shutting down 3DS + Wii U online services, see our post

Need help with scrolling map.

Root / Programming Questions / [.]

blizordCreated:
I'm making this small game called Hoppy and I'm having trouble with making the map scroll. It starts scrolling at first but then there's an out of range error on the bgput. I think it has something to do with the bg getting put off the screen. Also, I'm sorta using Discostews Petit computer background scrolling example. I just changed it a bit. Could someone try to find the problem? I'd really appreciate it. Just run it and then press play. Then press level 1 and it starts scrolling automatically. Sorry my code is a mess. KEY: R2VX32QE

Okay, so I seemed to fix the error with BGSCREEN but now the bg tiles are sometimes not getting placed according to the map array. It's also a little glitchy and slow.

So I looked at your program this morning, and then again tonight. I think I've figured out the problem. The glitchy and slow problem was easy to find and fix. The program as you had it scrolls slowly and places bg tiles on the screen instead of off the screen. In the game loop, change the value of "1" in the equation "BGCX=BGCX + 1" to something a little higher (like 2 to 4ish) and the game will scroll faster. To remove glitchyness, change the equations calculating XE in @UPDATEFULL to XE = XS + 24 and in @UPDATERIGHT to XE = XS + 25. I was able to sidestep the map array problem, but I still don't understand what's wrong. By altering level 1's DATA into longer strands and basically combining the two FOR TO NEXT loops that define the map array, the program laid out the level correctly, but I can't figure out why you can't use two separate loops and/or what the game is reading/how the map array gets defined incorrectly.

Naturally, I would write a post saying I couldn't figure it out and then I figure it out 20 minutes later. When you are setting the values for the map array, there are two FOR TO NEXT loops. Change the second loop to this: FOR T=0 to 14 READ L$ FOR I=0 to 22 MAP$ [ I+23, T] = MID$(L$,I,1) NEXT NEXT The solution is to remove the third variable. The way you had it setup, the program would read one line of data and then repeat it over and over, copying it into all of the values for the map array.

I know I should of updated this post but I already fixed all this stuff. It's still laggy though...

Like it flashes black once in a while. Thanks for the comments though. I appreciate it.

I wasn't able to reproduce your problem, but if the screen is flashing, it could be that the program/ SmileBasic/your DS is having issues loading all of the graphics. At least I think that's what caused this kind of problem in Petit Computer.