Pycraft progress report!
Tags: python, gamedev, opensource, programming
Published: 2022-11-07 20:06:35

Hello there everyone!

This week has been very busy and involved a lot of writing as we work towards the next article for Pycraft!
This next article will be for both the month of October and November combined, simply because we don’t think that we will be far enough through the redesign of the benchmarking process to be able to write an article covering the latest features added to the game after the restructuring of Pycraft.
This is also going to be a huge article, we are expecting it to be at least double the length of the ‘average’ article for Pycraft, this is because we will be writing about Pycraft v9.5.3 to v9.5.4’s major settings redesign, and also about the restructuring of Pycraft as a whole, and there is a lot to write about there.

Because the next article for Pycraft is going to be so long, it will take some time to write, which is why we have been dividing our day into two. We have now finished adding in the major features to Pycraft v9.5.5 and are now working on minor feature improvements and adjustments (which we call “feature tweaks”) as well as the large-scale testing of Pycraft and everything that has been changed in the large-scale restructuring of Pycraft – a big task!

Currently we are about halfway through this process, which isn’t too bad considering that we only started this process in earnest at the start of November, after the addition of the new load screen. We are working our way through Pycraft in a very specific order, starting with the boot-up sequence, then the credits and settings menu, and then on to every other GUI in Pycraft. It’s important to note that at this stage we are testing the settings menu, and any change we make to the settings menu, we must then go on and test in every GUI affected by it, meaning that testing the settings menu has been a lengthy process, but we are nearly complete on that process now. From there we will then be moving onto the home screen.

So, we have been very busy this week, with both writing out some of the article for Pycraft, as well as the large-scale testing of Pycraft, but in addition to that we have been making some under-the-hood optimisations to certain areas of Pycraft we feel could be better. Not least handling controller events. Controller events were added to Pycraft some time ago. At this time Pycraft was much less unified, we had events being handled individually by each GUI, and the events system for the 2D engine was completely different to the 3D engine, involving a completely different implementation involving threads, problematic behaviour and different modules. In this restructuring of Pycraft we completely removed all trace of the events system for Pycraft, including keyboard, mouse and controller, and built up two universal - but fundamentally different - event systems for the 2D and 3D engines respectively. We did have the option to combine the two events systems, however, not only would that mean we have one, longer and more complex event system, it would involve a lot of work as the main events system for Pycraft’s 2D engine is part of a whole host of basic GUI required tasks, from handling commonly used events to behind-the-scenes tasks like calculating FPS and average FPS for the current run. These tasks are commonly called in every GUI in Pycraft, although it offers great customisability, so we can adapt the call to be suitable to different GUIs in Pycraft.

The events system for the 2D engine can be found here, closely linked to the events system for keyboard and mouse inputs. For the game engine things are a bit more complex, events are handled uniquely to the rest of Pycraft, however we have tried to make the structure of the two events systems as close in style as we can. Previously we had the events system for the game engine running in a separate thread, which wasn’t great for development purposes as it meant a huge amount of additional complexity to an already complicated game engine. This was made possible with the switch from Pyglet to Pygame, which natively supports controller inputs and brings the windowing engine in line with the rest of Pycraft.

The keyboard and mouse events systems had been added back into Pycraft some considerable time ago, however the controller events system we had left out as we wanted to make sure we had the other input events working OK first, to avoid adding additional complexity before we knew that the events system works as expected. We have redesigned the events system for Pycraft from the ground up, so not only have we improved controller support, but we have also improved the end user experience on keyboard and mouse too, and we added the majority of the events system for the controller in this week.

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


![Seasonal events for: Bonfire Night!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z2rcofc5w7bamneyaohg.png)


![The original load screen wins the load screen vote and will be added into Pycraft v9.5.5!](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/51gfj5lhtruzicwirrlb.png)