So this week has seen some major progress with Little Bit Lost and I am very happy to share this with you.
Last weekend I was really keen to nut out the some more depth to the game and that was in the shape of biomes. A biome is an environment or ecosystem where the conditions will be different from others, for example a desert or and ice tundra. In the case of Little Bit Lost where everything is that much smaller I am introducing a much more micro biomes. I have plans to have area like patchy grass, sandy wastes, garden bed etc. The introduction of biomes meant that as a programmer I had to implement better structures, I had to think about different procedural generation processes that I wanted to use and I had to make everything more efficient.
Firstly, the better structures required a lot of my code to be refactored allowing for me to better follow the flow and remove some lingering ‘bad’ code which in itself was a major efficiency boost to the project. From here I was able to implement the structures of biomes and implement a ‘default’ biome that I could begin testing on to ensure that things worked as expected. I allowed the biome to control height mapping based on its type and set its probability of occurring in the world. With in the biome class I have it control the allowable voxel types as well as the allowable terrain clutter. I now can implement any number of biomes but at this point am only experimenting with two.
At this point I was already very happy with the weeks progress and could already see the benefits as the game ran a lot smoother and was a lot more interesting to play, but I was getting some odd clumping of objects and I was not very happy with that so I needed to expand on my procedural generation functions. The perlin noise function I have been using up to now (which you can get from here credit to Keijiro Takahashi) was ‘unseeded’ which meant that the results where consistently the same every play through. This is something that needed to be changed or replaced. In this case I chose to modify the code. This was quite simple to do at first as it simply requires a portion of the code which is a large array of randomly order unique numbers to be populated from a random function which is fed a ‘seed’ and results in the same string every time for that ‘seed’. As Little Bit Lost progresses this ‘seed’ will be a user set value and will generally be related to the game name that the users sets. This is a common approach used in many procedurally generated games.
Now so far so good yet I had missed something in the seeding of the array and it was now 4am and my brain’s capacity for pattern recognition was gone. So instead of been a good programmer and using code to identify a duplication in the array I chose to do it by hand. What was I thinking?? Well I guess I was thinking it would be like counting sheep and I would get tired enough to stop working when I should have been sleeping. Brain’s cruel trick was to get so engrossed in the task that it didn’t care. And after another hour I determined that the duplication was actually the first and last number of the sequence… The great part though was now the code works perfectly and I got some sleep that night and plenty more the next. There are still some other noise functions that needed tweaking but I will go into more about noise another time.
Lastly I needed to improve the overall efficiency and I was able to do this very simply by tweaking some code to run less often per frame. This process got me to a point though were I really needed to think about CPU time budgets and how much load I can process to allow for 60 frame per second. I have started to calculate out things that include theoretical max speed of a player to allow for this frame rate and will eventually play a major part in the speed of the insects in the game that the player will eventually be allow to ride…
So after what has been my longest blog to date please feel free to check out the game loading at run time in the below YouTube video. Check out the frame rate in the upper right corner maintaining at close to 60FPS. I am aware of the flicker on the terrain and this appears to be a combination of shadows and MIP mapping and I will be addressing this in the near future but until then I hope you like the progress thus far.