Week 1: Strong Start


I may be spending too much time working on this...

But I got a lot done!

- File System -

One of my goals for this jam was to make a file system ("cave") that was completely deterministically generated, as in it shouldn't matter what order the computer processes the data in it will always come out with the same answer. This was accomplished primarily by something I never really thought about before and still don't really understand... Hash Functions!

My prior experience with hash functions was only with vague knowledge of their use in pseudo random generators, hash tables (?) and probably something to do with encryption. Needless to say I did not know what they were. Essentially hash functions are methods to input numbers and do math on them so that any two numbers input into them give an arbitrarily random number as a result with a distribution that's approximately even over the total range of the data type size. There are a lot of hash functions available, and some of them claim to be hyper efficient, but when I was looking at a lot of them I couldn't figure out how they actually worked. Eventually I found the FNV hash, which seemed to actually use real numbers that I could follow the math of.

I'm half convinced the people who come up with these hash functions use black magic to make them. They somehow find the only numbers that work, and if you change the number they are using slightly the function completely fails and gives terrible results. Either way, by using their numbers I was able to make a half decent hash function that doesn't seem like it kills performance when I'm calling it 200+ times on the first frame.

To generate the file system I define how many "nodes" (folders) are on each level so I can define how the system structure looks. Generally the file system is narrow at the top, gets very wide near the middle and then thins out so that the really deep folders (which are supposed to have really good loot) are not as common and really have to be searched for. Then each node generates a hash value which is modulo against the number of folders in the layer above to get the folder in the higher layer you get to that node from.

Resources are distributed based on a function that decides the average number of files should be in each folder on every level. The resources  then go through a similar process as the folders, where they generate a unique hash that determines which of the nodes on the level they are assigned to.  For the value resources (ones that give you points) they increase in quantity as the system gets deeper, and then the large versions of them start replacing the smaller ones after a certain cutoff. The data resources (that give you time) have a constant average amount per folder no matter the level.

To make sure there is minimal correlation between parts of the generation (the exact same values being fed as the inputs to the hash function) every object is defined by: a) its depth, and b) its unique id for that layer.


- The Malware is Creep'n In -

The second major system I put a lot of work into this week was the malware system. Which I more succinctly refer to as the delving system, but is essentially just the malware portion of the game.

 A fun visual addition (that I probably shouldn't have spent this much time on before the polishing phase) is the "Process Thread", which I am very hilariously representing with an actual thread (you may LOL now). The thread doesn't really do much to gameplay, and honestly makes the experience worse since it obscures the screen a bit, but I'm keeping it because the joke is too good (and it does add a bit to the malware, and cave delving feeling). The thread spools out from an actual spool and then connects the headers of all the browsers you open. The backend of the thread is composed of a line renderer (which I wrote a hermite spline controller for) and a camera that renders to a low resolution render texture.

I spent way too much time on shaders (once again way before the polishing stage) but they were mostly just variations on the same shader I wrote to add colored noise to the thread. The shader for the thread takes in a noise texture with rgba channels and then applies it to a base color when the alpha threshold on the texture is high enough at the given UV location. This creates a cool effect where the thread (on top of being pixelated by the render texture) has random glitchy bits in it that make it feel more malware sourced. I originally intended to apply this shader to all of the malware sprites, but it became a bit messy looking (I may try again in the actual polishing phase).

The other major shader I did was a gradient shader that just selectively applied a base color. (This will become important for the next section)

- Avoiding Total Meltdown -

While the process thread stuff ended up being a fun little distraction from what I was working on, the actual gameplay part of the delving system is the "heat" mechanic. As the malware gets deeper into the file system it requires more processing to run which generates heat. This causes a thermometer to fill up, which when it does... well you can see for yourself:


(I'm quite proud of how the explosion animation came out)

This mechanic is to force players to not venture too deep, it replicates the feeling of danger that comes from delving in real caves, and it requires players to return to the surface often.

- Next Week -

There are still a few more delving related things on my list (mostly having the overheat countdown actually do something). But then I'm starting on the collection system. When that's done I'm hoping to have a complete minimum viable product for a purely singleplayer version of the game. Which is where the scary part comes in, because after that I have to start writing netcode (:o) which is always intimidating.

Heres to being just as productive next week!

-Thaddy