I'm currently working on a simple 2D tile based game. I want to let users (=players) to create really large maps without problems with performance. That is why I'm searching the way how to optimalize the code before I actually write it. I've read some articles about streaming tiles, but I don't think I've understood them at all.
Map is stored in simple INI file like this:
[MAP]
title = "Test"
tileset="test.png"
width = 5
height = 5
tile_widht = 32
tile_height = 32
[LAYER]
type="background"
data="0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4,0,1,2,3,4"
# ... items, NPCs and quests definitions
When loading a new map, I'm reading the file line by line and parse it. After that, I create array of Tiles (std::vector tiles).
Every tile knows it's own position, value (which is the number indicating the tile from tileset), passability (number which indicates how hard is it to pass this tile), inventory (list of items lying on this tile), NPC list (list of NPCs standing on this tile) etc...
Now comes my problem. How to stream the tiles? With this file format it seems to be inpossible to load data when needed, so I have to load them at once.
Only thing which comes to my mind is, to store map data in arrays and create Tile classes only when they are really needed (if the tile position is withing the screen) and unload them after leaving the screen...
My question is, how do you suppose to solve this problem? How do you do it in your games?
Thank for your help and sorry for my English.