I was planning a new kind of level system for the last days.

This evening I started and finished the system for a testlevel.
To apply it to my game there some further work has to be done.

The central idea is to split each level up into 12x12 (144) sectors with 1024x1024 quants side length.
Most of the entities (there are only few exeptions) are defined as part of one of those sectors depending on their position.
Thus all the entities filenames, position, angles, IDs and skin-numbers have to be saved in an external file so that I can get everything back when I want it.

The camera is now in the center of 9 sectors, each time the camera passes the border of one sector and comes into another one, a function checks which entities have to be removed because they are no longer in one of the 9 sectors surrounding the camera. After that, the function looks for the sector which came new into the 9-er block around the camera an loads all the entities in them from the data stored in the file.
(the algorythm has ~90 lines of code and 6 while-loops in each other)

This has a few nice advanteages:
- level load times drastically increase because only ~6% of the entities have to be loaded and all the traces to put the entities on the ground are not needed anymore, since the end-position is written into the data-file.
- Framerate increases well (around 10 FPS in my demo level expected) because only 6% of the entity amount is there
- If I want to change the names of entities now, I do not have to replace all the entities in the level anymore, I just have to go into the Data file and say "Replace With" to have all the entities exchanged.

There is one disadvantage:
- Going from one sector to another causes a short entity creation time.

Thus I even could use my data-file as a text-based level editor now.


Maybe a little screen to show how it works from my testlevel.
The red 3x3 square is where I came from (the centre is attached to that very thin sword standing on the diagonally crossed fields and not to the camera yet) and the yellow 3x3 quare is where I went to.

Each of the white/black squares is one sector (I can change it very easy, all is made with defines).

The transparent objects were created or removed, depending on if the sector felt out of the 3x3 square or came into it, the non-transparent ones stayed.

That's how the file looks like internally, after each sector name, a list of entities is written, depending on how many entities in the sector are:

Sektor0
MEHLSA00.MDL,-224 224 14 90 0 0 1 55
Sektor1
Sektor2
MEHLSA00.MDL,-96 224 14 0 0 0 1 55
Sektor3




My project Schlacht um Kyoto - Das Samurai Browsergame! (sorry, german only)