Home|Projects|About

Terraria Clone, C++, 11.20.2021

Being probably the largest project I ever worked on up to this point, and being that I was cateloguing every step of the way in my devlog discord, this project holds a LOT of lore behind it.
To start, I would like to give a little background. I have been playing terraria since before it officially released (I played the awful leaked pre 1.0 version)
I LOVED Terraria as a kid, especially when it was all new. The exploration, the items, the new enemies... The game felt so huge, with each step further in any direction I found more ... this is all helped by the fact that I was very bad at videogames for most of my life.
But still! And then, 1.1 just made so much sense! Now that you've explored the entire world, have new features added to your world to explore! New bosses to fight!

But it just... Doesn't feel like that anymore. Maybe it's because I have a complete understanding of the meta, maybe it's because I'm not a borderline retarded 10 year old anymore, but the game just feels... dull. It feels like its no longer about exploring, its about grinding. New content keeps getting added, theres such a powercreep, and old content is left in the dust. The deisgn has changed so much, all the old elements just feel like parts from a bygone era.
Why make armour from ores when you can just do one simple trick and get a vastly superior set for half the effort? Why go exploring when you can just cheese an optional boss and know you're going to get something worth your while.

Its also just so... easy. Yeah, sure, you can play some uberdifficult secret seed on the super duper hardmode, but whats the lose condition? If you fail, what do you lose? Really, if you, say, fail to kill a boss, you only really lose the resources you used to summon and in fighting the boss. Which you can get by grinding more. The game is now a boss rush with needless grinding inbetween. You fail? It's probably not your strategy, its not that you failed your build and need to start over. You just need to grind more to get more resources to get another attempt to kill the boss.
Its just so dull. You play the game to play the game, there's no lose condition, you just get up and try again. If you've done it once, you've done it 100 times (and I have done it 100 times)

Anyway, onto the game I wanted to make
Keeping all my gripes in mind, I wanted to make a game similar to terraria. You would start at the surface of a narrow, but INFINITELY deep world. As you continued downards, you would find new resources, dungeons, enemies, etc. I even considered letting you go into the sky. At first its just birds, but eventually you break into a cloudscape and fight thunder gods or something. Just an idea.
As for what I actually made....

Obviously, this isn't much of a game.
Though, this was just me trying to learn a graphics library that wasn't made in the 90's for the first time. A few hours later and we already had this.

Why the recording is off center, uhh, I have no idea. I don't have this version of the game anymore, so I can't get new footage.
But this was big! Taking what I had learned with the fps Rogue Adjacents, I made a pretty robust collision system, which would only get better as I kept working on it. Right now the world is hard coded and player is only one point, but that didnt say that way for long.

BOOM! Using the perlin noise code that I had made previously, I made (admittedly rather poor) prodedural terrain! This is also around the time where my original vision first started to crumble. I had set it up to where the character looks like hes underground 24/7

Next up, minimap and dramatically improved terrain generation code! The red box isn't anything I added, it's a part of the screenshot. It shows where the player camera is in the world at the moment.

Here I went hog wild. (almost) All new textures, improved mining/building mechanics, resource gathering, and (something you can't tell in the video) INFNITE CHUNK GENERATION. Another thing you wouldn't be able to tell, I wrote the text displaying logic myself!! It was one big texture with every character I could use, and some cursed logic to iterate over a string and print characters one my one. It could even handle return characters!
My chunk loading code was actually one of the main reasons I stopped working on this project. I was sooo scuffed, I had no idea what I was doing. I think from this point forward nearly every bug comes from this code interacting with other parts in some way.

Next up was explosions. You can throw a little bomb and it will explode. If you're wondering, I stole the explosion logic from minecraft almost purely. Not actually sure how Notch had it set up specifically, but it had to be about like this.


Next up I wanted to implement dungeons.
Pretty clearly, this isn't the game, but it's a seperate program I made to test out the dungeon code, made with intentionally compatible code structure. Doing things like this is proof that I really was starting to mature as a developer.

After some very very frustrating troubleshooting involving accidentally leaving in legacy code which slowly corrupted the game files, I got dungeons working. This is a fairly small one, but its the only one I had footage of.
I also added sulphur, which you could mine and use to throw the bombs from earier. Sulphur is also explosive itself, meaning you can make little nukes my exploding sulphur deposits.

Next up I added a particle system, and added simple "pickup" entities that hold the resources when you break tiles.
This particle system was actually incredibly robust, and there were configuration options to have more or less particles, if your computer couldn't handle all of them.

Next up was a basic lighting system. I really regret not doing this one better, but it is what it is.
If you were wondering, the player emits "light" and every tile in the world casts a ray to the player, counting how many spaces it touches between the it and the player. If it collides with a wall, it counts as crossing a number of spaces equal to that walls hardness value. For performance reasons, only cells with light levels lower than their neighbors are allowed to check for distance. Not sure why I did it this way, to be honest.

After that I added collisions between entities. Here, they just fly towards the player.
I did this by creating my own collision resolution. While actually more glitchy than the one I used in the 2nd Rogue Adjacent (I have no idea how that one ended up being so bugless), this is my 2nd best yet. It would automatically divide entities into a grid of spaces along their surface, and check along the velocity vector if any points intersected with either a wall or another entity. I even used a spatial partitioning scheme, it ended up being VERY robust, could handle thousands of entites. Its one of the things I'm very proud of in this project.

The next thing I tried to add was pathfinding.
...

For some reason I could never get it to work. The smoke particles show the path the entity is trying to take. I think it was due to a couple reasons. For one, I was trying to be tricky with how I implemented A*
I was trying to dynamically create the grid of cells used for pathfinding (I mean, hey, if their values are unknown just don't allocate them yet!) This, combined with trying to think of a good way to implement jumping proved FAR too difficult for me to manage, so I simply gave up. Enemies just walk towards you, not respecting walls at all.

And that was the last time I ever touched the project. I had recently gotten a job, and didn't have as much time to work on the project. And when I did find time, I found that I had no idea how to navigate a codebase I had been maintaining for several months, especially considering I had doubled in quality as a programmer over its entire duration.

If you were wondering, I pretty quickly realized that I didn't want this to be my dream 2d survival platformer. I decided I would work towards a wave based survival game, where you gather money to buy weapons to survive zombie attacks. If you've played the xbox indie game Zobmie Estate, think that plus terraria.

If you would like to try it out, you can try the last stable release here. I didn't ever get around to actually adding any gameplay, though...