Thoughts about the Onslaught map generator
With the 2nd Tutorial under my belt, I’ve ben thinking about the map generator which is the subject of the third tutorial. I suspect it will be based on the Empire map generator which you can read about from an earlier blog post.
The difference is that there will only be one continent not several and it has to occupy between maybe 50% and 80% of the specified map size. These are 20 across by 15 deep (small), 30 x 20 across (medium) and 40 across x 30 deep (large). On a 1024 x 768 Window, I managed to fill it with 31 across by 28 deep, so I’ll need a larger playing Window. The current one is 1024 x 768.
The Empire generator works by first scattering a number of land and sea points in an empty grid then growing layers around each point in the empty cells, stopping when a non-empty cell is found. I’ll need to modify it so that the starting land points are near enough to form a single continent when grown and reject any map that has 2 or more continents.
I also put Onslaught on my Raspberry Pi and found that it runs a lot slower than on the Hyper-V Ubuntu. I can only put this down to the number of hexagons. a screenful at 1024 x 768 is 31 x 28 hexagons and that requires 868 blits ( each a call to SDL_RenderCopy). Each blit copies 1088 bytes in VRAM. That’s almost 1 MB of VRAM being copied in itself each frame which is not that much for a GPU but there’s probably some overhead for each blit and I imagine that could be the performance killer.