I'm playing with 2D games programming. My toy project is a sailing game with explorable islands and more, but at the moment I'm trying to find the best way to apply "beaches" (i.e. soft ends) to the otherwise fairly rough islands. Tile size is 64x48.
My present solution is to iterate through each tile and look for surrounding tiles, and based on their surroundings, replace the water-tile with the correct texture.
I realise that this is a very flawed approach as it is:
- Incredibly inefficient as the surround method is invoked for every tile, even those affected by the change
- The order of execution might imply that some tile changes are overwritten
Do you guys have an idea how I might get around and solve this in a better way?
Thank you!
edit
This algorithm is performed when the map is being loaded.