Pycraft progress update!
Tags: programming, python, gamedev, opensource
Published: 2023-02-28 16:13:22

It's time for our weekly progress summary for the week beginning the 20th of February 2023 - and what a week it has been! This week we have continued with the ongoing work on Pycraft v9.5.7, with a particular focus on improving the way data is transferred through different areas of Pycraft's source code.

So, last week was extremely successful and we managed to finish phase one of this process of changing the way data is transferred through Pycraft, which consists of removing all the parameters that made use of 'self'. 'Self' was used as a reference to an instance of Pycraft's registry that we would use as a central place to store variables often used by Pycraft. Initially, just this reference was passed through every individual section of source code, which made the transfer and modification of the registry easy, but at the cost of reliability. Then, in Pycraft v9.5.5 we made many major changes to Pycraft, one of which was only allowing 'self' to be used by main menus, with utility programs taking only the information that they needed. This worked very well and significantly improved the readability of Pycraft. However, this came at the cost of Pycraft becoming much longer - reducing the advantage gained by the changes we made.

Now, we are working through Pycraft's source code and undoing these changes, but don't worry, this doesn't mean we wasted our time in Pycraft v9.5.5, many of those changes we made then are still used today. Our solution is for each utility program to have its own instance of Pycraft's registry, but make that registry shared. This way we can transfer all the variables used in the registry behind the scenes, vastly simplifying Pycraft, shortening it and improving reliability and editability.

Since last week, which we can consider almost as the demolition phase, we began phase two of the process of changing the way data is transferred through Pycraft, which we can consider as the construction phase. In this process, we begin to actually start adding new code to allow different sections of Pycraft to take advantage of this new principle. We had feared that this would be a very slow process, however, the utility programs have significantly increased the speed of this, as it allows a single change to make multiple other areas of Pycraft work.

This meant in almost no time at all, we had Pycraft at a state where we would run it, and get to the home screen. This is where our real genius comes in though. Every single 2D menu, including the map, inventory and load screen for Pycraft follows what is essentially the same design, and so by working on the home screen and getting that operational, already makes a significant chunk of the other GUIs work, and as such, our progress was accelerated and we have been smashing through our plan again, and now the achievements, character customiser, credits, home screen, settings and startup menus work.

Now, this progress is in and of itself amazing, and we can now start to see visually the progress we are making - which we expect to be fast as we are not changing the source code itself, just the way different sections interact!

This now means we are about ready to start work on other areas of Pycraft, and having now finished the 2D engine, we can move on to the 3D engine, including the main game engine, the load screen, the inventory and map sections too (although they are technically 2D, they may not end up remaining as such). And we have more good news, the first stage - the destruction phase - we rolled out to the whole of Pycraft, meaning we are now comfortably well over 50% of the way through the process of changing the way data is transferred in Pycraft and the installer...

...The installer? We haven't talked about that much yet, but don't worry, we have plans to do the same thing we are doing to Pycraft now, to the installer, although we haven't started that yet, but will be doing that as well in Pycraft v9.5.7, but will also incorporate the changes we had originally planned into Pycraft v9.5.7 too. The installer is also based on an older architecture than Pycraft is currently, however by the end, we plan for them to both have the same architecture where possible, with a centralised registry that each file of the source code can instantiate!

Now, we have lots to show for our work this week, so it has been difficult choosing the best ones, but here we go - as always we hope you enjoy!


![Pycraft's home screen following the changes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/12tfv14b47s2x7nbnvv0.png)


![Pycraft's credits screen following the changes](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yjs1b17ufkxvtkpdvq93.png)