Hm… that’s a very interesting thought. It might slow down the level editor process some, but it should decrease map size and map loading times. It has a rather unexpected side effect; I’ll explain by first explaining the current format.
A map currently looks like “hexstring,hexstring”. Both strings are divisible by four. Every four characters is a coordinate pair that ranges from 0-255 x, 0-255 y. These are then multiplied by 16 ingame, to increase the level size. Thus, I’m sacrificing precision to decrease level size.
The first string consists of n pairs of coordinates for the polygon, then two pairs of coordinates for start and end. The second string holds all the moveable objects on the map.
A side effect of this storeage method is that any coordinate in the level editor is rounded down to the closest multiple of 16. This allows for entirely straight lines for the polygon, which in turn lets you make lines with no width (that you can pass) to smaller polygons within the polygon. Due to how polygons behave when its lines cross each other, the new polygon will count as “outside” the first one. The collision checking in the game is done using a simple Polygon.contains(int x, int y), and so my method allows for caves with obstacles without having more actual polygons.
Of course, it’d be better to support several polygons, but as it is I’m only checking whether the player is outside the polygon or not. With more polygons, I’d have to check whether the player is outside the first polygon, and inside the rest of them, so I’d have to keep track of polygons seperately. This could be replaced by subtracting the main polygon from an Area, but that would instead decrease performance.
</long story>
The point is, if I changed to random approximation of maps I would most likely lose the ability to have straight lines, and thus the ability to fake having multiple polygons… I think? Currently, the maps compress well, and each map tends to stay at some 20-30 bytes. On the other hand, I have decided to only have small maps in the game, so randomization would help by allowing for larger maps… It might well be worth it. I’ll give it some further thought