Terraria Clone#

2 years ago I attempted to recreate Terraria with a friend using the Unity Game Engine which had limited success and ultimately left the project dead. But I did learn a lot more about attempting to procedurally generate a game world.

Generation#

One of the main parts of Terraria I loved was the world generation which I wanted to replicate as it is one of the parts of Terraria that gives the game infinite replayability. Rather than generating tiles when creating this algorithm we chose to place it on a texture instead as it would mean we wouldn’t need to optimize immediately as loading a large number of tiles will cause a large amount of slowdown.

We took the approach of generating each layer separately. So like Terraria, we created multiple layers, space, surface, underground, caverns, and underworld layers. Each layer with a different set of settings for its generation which would tweak a Perlin noise algorithm to create these.

It seemed good in concept but in practice, we ran into numerous issues with each layer. The first two layers worked as intended and created a nice surface layer. But we couldn’t get the caves and underground layers how we wanted at all and usually ended up a mess that wasn’t even interesting to navigate. Even with further tweaks to the algorithm, we could not get it how we wanted which would most likely mean a rewrite to these layers.

The other major issue was with the noticeable seams that would appear between layers which was most likely just a weakness to our original plan and could have been solved by blending two noise maps to create a far improved seam.

Unfortunately, none of these possible changes came to pass as motivation for this project was essentially gone. But would be an interesting challenge to revisit and possibly attempt to create in 3D rather than 2D.

Character Generation#

I did this alongside the generation algorithm. I decided to split each of the limbs of the player apart before giving each part a specific value which I would later use to recolor the correct pixels of the character.

This did actually function as intended with only one major issues. The first being with the current script setup you could change the color of each part only once as it read from the same sprites that were being recolored which could cause problems if the same exact color was chosen for two different parts. This could simply be fixed with a mask or lookup sprite which would solve this problem entirely though due to motivation with this project dying this solution was also not implemented in the end.