I have a functioning game map at this point, but I'm bothered by the fact that I can't get the map to scroll very well.
I have a map loaded into an array, it has a variable size, but it is square and goes from (0,0) to (Map.Size, Map.Size) (measured in 32x32 tiles)
The viewport, the screen that the player sees, goes from (0,0) to (10,10).
When I load the map I put a 5 tile buffer around the map array that the player cannot walk through, so that I don't get the dreaded IndexoutofboundsException.
After getting everything working I realized that when my player moves the tiles that are coming into view don't show up until the player finishes moving. This happens because I have the map moving a few pixels at a time during his movement, but I don't update his actual position until the movement is finished. I found a work-around by increasing the number of tiles drawn (now 0,0 to 11,11), but it only fixes the bottom and right side scroll issue, of course.
If I increase the number of tiles drawn on the left or top side (-1,-1 to 11,11) I get an exception. I tried catching the exceptions, but it slows my frame rate to a crawl (from 200 FPS down to 7).
A few ways to get around this, that I'm aware of:
Increase the size of the map buffer so that going one or two more spaces out to the left or top doesn't cause an error.
(the Dragon Warrior way)
Lose the buffer altogether and change my code so that when the player gets near a map edge it switches from him standing in the middle of the screen and the map actually doing the moving, to him moving around the side or corner of the map.
(the Final Fantasy way)
The other reason I'm interested in finally fixing this annoying issue is that I implemented irregularly shaped objects into the code. Since they fire (show) when their lower left-hand corner comes into player view, the bigger they are the faster they disappear off my screen as I move around.
I can post some code on here, but it's really dense stuff. I guess I'm looking for advice on what would be the better methodology rather than a code fix, for the most part.
That said, if you want to see some of it let me know and I'll turn a chunk of it into something readable and post it here