I'm working on a level editor for a 2D game atm, and I'd like to have the file you're editing to stream from/to a file or many files.
I've got Resolution 800x600.
I make sections outta 256x256 pixels. Where there are 16x16 pixels large tiles. Which makes 256 tiles per section.
NrOfSectionsX = ceil(resolutionX / sectionXpixels) + 2
NrOfSectionsY = ceil(resolutionY / sectionYpixels) + 2
i add +2 so I can get sections -1 and +1 outside of the screen so I got that in memory and can display it instantly without having to load anything.
However the problem comes when I wanna load sections outside the screen.
I store each section as it's own file. Where I call them for example: 0,0,0.txt being the upper left screen which can be seen when starting.
Then next is called 1,0,0.txt which is 256 pixels to the right of previous section.
Problem is. There's choppiness when I load these sections which are outside of the screen. It happens because I write sections to disk which aren't important anymore. and I read sections which become important.
So I put the level save/load in separate thread. Sure there is no choppiness any longer.. However, there is delay before they are presented.
So I thought, hmmm what about having one large file containing all the level data with pointer-data in the beginning of the file which says where in the file each section is... Sure that works.. However, what happens when data is changed? Yes that's right, it doesn't work, because you cannot edit stuff you've already written to the file.
I thought about putting it all into a zip file aswell. But there seems to be no libraries which can fix my problems.
Now I'm asking if you guys have any good idea to fix this problem?
If I remove the whole file i/o then my program runs smooth at 1000 fps. But sadly no sections are stored which kinda sucks.
Visual example of what I'm trying to deal with:
Edited by Elrinth, 14 October 2012 - 04:19 PM.