• Register
Post news RSS Dev Blog: Text files are the future

Text files are the future of Miner Threat. We will go back to '95 for this game.

Posted by on

Even though I talked about this last week, this week is 100% working and fully up. The level generation actually didn't work last week because of about 10 bugs, but I dealt with all of them, and now it works. The level generator and everything related to it is the exact same, it just uses text files instead. It used to take 15s to generate levels, now it takes under 3.


That is the chunk file for one of the starting chunks, and now you can tell that I did what I said I might. You can have little tags to modify how the level is generated on a low level. Technically, you can place those tags anywhere between ~begin and ~end, but it's easier to read at the top. (Just noticed "rectangular snip.")

The game does have a loading screen at the start of the game now, entirely just to load the chunks. The old system read the image at run time, which is awfully slow. I couldn't do that with text files, because they aren't handled the same way. Instead, now when the game starts, it makes almost a matrix of each chunk. For those who don't know what a matrix is (It's a nerd thing...), here is a diagram that explains it.


That is what the chunks look like in ram. Each number represents something to place. Loading data from a 2D array (the thing in the picture) is much faster than loading it right out of the text file, so that is what actually gets the speed. Technically, I could have done that with the images, but then it would be non-mod-compatible, and disallows the user to modify them. (Plus, it's easier for me to edit the text files.)

Kind of a small thing, but I fixed the player starting in the floor. So that's something.



Post a comment
Sign in or join with:

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.