Did you know Dune 2 used to have 62×62 playable maps? It also had an ‘invisible map border’, so technically the maps where 64×64 (max 4096 tiles/cells). The invisible map border could be used to make it possible to have units move into the map seamlessly.

When D2TM was being created (way back when), the idea was to be able to play Dune 2 maps. Hence, the dimensions of 64×64 where fixed within the code.

Now, with a new feature coming to play larger maps I had to revisit the code and make the game flexible with its map dimensions.

Super easy right?

Well. No. Changing the code is not as easy as changing the number 64 into a bigger number (128, 256, etc…). The first reason is that bigger map sizes do not apply to the original campaign. Need to deal with that. In fact, the campaign has 32×32 sized maps in the first levels which D2TM does not even care for. Also, you need to think about how this impacts the minimap (it will break with > 128×128 maps, because the minimap is at max 128×128 pixels big).

So how to approach this? Well the first step is to remove as many references to the number 64 as possible. This is partly just old/bad code that needs to be DRY‘d . On the other hand it makes sense to keep data in one place. Meaning ideally you have a “Map” data structure which knows its dimensions. Other parts of the game could ask for the dimensions, but should not be the owner of the data.

Once we have done that, we can make the Map data structure flexible internally, calculate cells using any width/height the map can have.

Then, we can try it out, some parts might still rely on a 64×64 map structure (Skirmish map previews do). So that needs to be tackled.

The easiest test case would be to check out smaller maps first. This removes the complexity with the minimap (as long as the map fits within 128×128 pixels).


If you play version 0.5 and play skirmish map “Cliffs of Rene” you will notice that the map renders a bit odd, it is all sand below… or is it?…

What really is going on here is that the map is *not* in 64×64 format. The map format (INI file) allows for this, but the engine simply does not care and has by default all other tiles as sand. Hence you can play this map, but it looks odd.

And now?

This is all still work in progress, but it is starting to look like this:

Also notice the minimap, it still naively draws the map from the top. This can be improved by properly aligning.


The feature is not yet complete. You can see the current todo’s for that.

Basically it is now at a stage that I have to test the current code thoroughly with skirmish maps (smaller and 64×64 ones) AND make sure campaign mode still works. Then I want maps with 128×128 size supported. The easiest approach would be to have random maps always be in 128×128 size; I don’t feel like having to redo the whole “setup a skirmish game” screen yet. The influence on the minimap should be minimal.

After this feature, further improvements would be (but not coming in 0.6.0 though):

If you made it this far, kudos to you!

Thanks for reading!


Comments are closed

Want to support? Please consider donating via Kofi.