Isometric Terrain Map
-
Inspired heavily from @mixaal's 3D Terrain Generator post (and directly using one of the noise algorithms he linked to), I thought I'd try my hand at the world generation scene, but in 2D!
Kenney has a ton of really nice isometric spritesheets, so I was inspired to try and make a world in a sort of OpenTTD-esque style. So far all I've got is the ground levels and hills, though. Every time you start the game, the map is randomly generated using the Perlin noise algorithm, and divided up into a number of height levels.
Then that's where the real fun began for me. Figuring out how to properly calculate a 2D pixel coordinate for isometric tiles that technically existed in 3D space cost me a few days of research and trial and error. This was a great resource to start with, but I had trouble introducing height. I see now that the reason I had trouble is that Kenney's Isometric sprite sheets aren't fully cropped to the height of the actual image, so I had to do some extra subtraction there. The really fun part was going through each tile and figuring out which hill sprite to render. I ended using a kind of bitflag lookup array that I think works well.
As you can plainly see, the rendering function definitely needs optimization..but for an initial proof of concept, I'm relatively happy!
The initial grayscale image you see is a visualization of the perlin noise algorithm (after some post-processing done by me). The brighter colors represent higher elevations.
Now, I need to go back through and clean up this code so that I won't die of shame when I share it out...
-
There'll be no shame here! That is a fine proof of concept and definitely a great foundation for a turn based strategy / rpg - Advance Wars... Fire Emblem oh me oh my!
-
Very exciting indeed.
-
Hi @Eearslya ,
If you want to re-use my code, feel free to add me and you can copy/paste parts you need. OpenSimplex python implementation is quite long to rewrite and is distributed under MIT license, so no worries about re-usal ;)
Also if you want I think you can take a different approach, using 3D isometry and setting the mountain type to TERRACE. This will round up the height to some constant making those "jumps in height" for you., By setting the right fov and camera distance it might be enough with perspective projection as well.
-
@Eearslya said in Isometric Terrain Map:
As you can plainly see, the rendering function definitely needs optimization..but for an initial proof of concept, I'm relatively happy!
Please share your findings regarding optimization. I would find it very useful to learn more about what's slow or fast in FUZE, since there's currently no profiler support.
-
@Nisse5 I'm not sure I can really blame FUZE for the performance of the rendering function. It's more of a product of how clumsily I'm rendering the tiles. In order to draw them in the correct order so they don't overlap each other, I'm drawing it layer-by-layer from top to bottom. Unfortunately, in it's current state, that for loop performs about... 5,120 iterations for just 1,024 draw calls. I believe I can improve performance greatly by taking another approach. The other slowness my program encounters is during the noise generation, which calls roughly 262,144 functions to generate the full map, and you can hardly blame FUZE for not liking that.