Pycraft progress report!
Tags: python, gamedev, opensource, programming
Published: 2022-11-21 19:59:22

Hello there everyone!
This week we continued the large-scale testing of features in Pycraft. This week we focused on 4 key areas, the game engine, the inventory UI, the map UI and finally – at the end of the week – the installer for Pycraft. All 4 areas have seen varying levels of changes in Pycraft v9.5.5, ranging from bugfixes and feature improvements to the map UI through to the complete restructuring of the game engine. Regardless of what form of changes we made, because there have been changes and improvements, we therefore must make sure to test each area as necessary.

We started this week working on testing the game engine for Pycraft. This is a key area that we want to make absolutely certain we get right as the game engine was one of the key motivators for the change of direction in development of Pycraft v9.5 to focus on restructuring and improving large areas of Pycraft before attempting to continue with development of Pycraft v9.5. We want to make sure that we get the game engine right now because we will be building off this area of Pycraft more in the near future we want to make sure that we get this right now as to avoid additional work in the future. So after stringently testing the game engine and fixing the identified bugs – fortunately nothing major – we were able to quickly reflect on the huge number of changes to the game engine that make it even better than before, then moved on from testing the game engine to testing its companion UIs, the inventory and map.

Of the two companion UIs to the game engine, the inventory is by far the better designed and implemented of the two, so we decided to start by testing this one first as we knew that if bugs occurred in the underlying architecture of the inventory, then likely the same bug would appear in the map UI as they were restructured in tandem so they would follow the same behaviour. Because of this, all bugs identified in the inventory, where also checked for again in the map UI where necessary to be extra thorough.

Discussing the inventory UI more specifically here, but this UI suffered from minor bugs, mostly issues with how translated text of different lengths where handled. The same bugs occurred in the main menu and settings menu, however the way those options where handled is the same, but this approach is different to the way it was done in the inventory. So, we therefore decided to re-do the approach in the inventory with the method we used in the main menu and settings menu as we found this to be the better designed approach, and means that where possible the same implementation is used to fix the same problem, making debugging and future work on the code easier. An example of the problem we had in translations is shown below:
 
In the image above, the hitbox for the menu elements is outlined in red, and you can see that for the text translated to a different language, in this case Spanish, the hitbox has not adjusted to represent the longer text. For the bottom element; ‘options’ you probably wouldn’t notice it, but it especially becomes a problem the greater the size difference between the translated and original text. This was the most common bug we identified in testing the inventory UI, so fortunately it was a relatively simple set of fixes to implement.

With the testing and bug fixes of the inventory out the way we could progress on to work on the Map UI. Our testing in advance of the inventory UI was massively helpful in identifying problems with both sets of UIs. Now the map UI was originally just a placeholder for a later addition where we would generate the map in code (instead of drawing out by hand which is how we made the current map for Pycraft which is attached at the end of this post) by generating some form of heightmap of the terrain from a downwards perspective and then texturing this appropriately. However, in the immediate weeks after adding the map UI there was a major change in direction of Pycraft’s development because we had reached problems with implementing new features in the game engine and as such needed to go back and improve on things we had already worked on before we could continue adding new features.

Because of this, the map UI – which was only meant to be a temporary placeholder – hasn’t been updated significantly since it was first added some time ago. Since then, we have rolled out changes to improve or extend the functionality of some UI’s in Pycraft however the map UI almost never saw these changes with the belief that it would be changed soon. This meant that when it came time to testing the map UI, we were fully expecting there to be bugs, however the number of bugs we found was in some ways terrifying.

None of the bugs we discovered with the map UI would harm any other software or hardware on your system, and to our knowledge we where unable to find any bugs that would cause the UI to crash, however the number of minor errors failing silently, visual anomalies, bad visual design and more wasn’t great. In response to this we have patched up the UI as best we can and have brought forward plans to improve the implementation of this UI as far forward as we can (and we will be approaching this in stages as a result, something we will look into closer in the next article for Pycraft).

With that out of the way we ended the week off with the beginning of work on the installer for Pycraft, at this point we are setting up an environment to which we can test the current application of code, instead of making changes and improvements once the release was live. We where also able to do a full run through of the installer and observe no crashes or strange behaviour, although an in-depth assessment on the installer, updater and uninstaller for Pycraft has yet to be carried out.

Attached below are some visual highlights from the last week of development!


![The current map resource for Pycraft, this is the original image and was not taken from Pycraft - This was originally drawn out by hand!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dgbxu9wfzvxzayd3inrr.jpg)


![The current map resource for Pycraft, this is the original image and was taken from Pycraft - This was originally drawn out by hand!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hvpeem2m339nipzodowz.png)