Repository navigation
Python Overview
Eric Froemling edited this page Mar 30, 2020
·
65 revisions
Ballistica consists of two layers; a low level layer written in C++ and a high level layer written in Python. Things such as rendering and physics calculations happen in the low level layer, and things such as game and ui logic happen in the Python layer. For modding purposes, the Python layer is the only really relevant one (at least for now).
This is a high level list of some of the tech changes in Ballistica vs the original BombSquad scripting layer. For detailed changes you can look at the ChangeLog, though admittedly not all Ballistica changes made it in there. In future incremental updates that list should hopefully be more exhaustive.
- Ballistica is now using a modern version of Python (3.7 at the time of this writing), whereas the old code was 2.7. There are some fundamental differences between Python 2 and Python 3 to be aware of such as the print() statement and new string types. Python's 2-to-3 transition has been going on for many years and there is plenty of information available about porting code. Moving to modern Python gives us lots of fun new toys to play with, including a better super(), data classes, enums, f-strings, and type hints. One thing to keep in mind is that, going forward, all Ballistica platforms will be targeting a single recent version of Python (currently 3.7), and so all code can target the exact feature-set of that version; no need to worry much about backwards compatibility.
- Ballistica has incorporated static typing into all of its Python code. This is currently being done with Mypy, though different or additional systems could be adopted in the future. Static typing can make code in a large project easier to write, more robust, and less prone to breakage, especially in cases such as ours where APIs are evolving over time. There are a number of useful tips in the Knowledge Nuggets page related to Mypy and type checking.
- Ballistica has adopted common code standards for Python such as Pep-8 which should keep things more consistent with the rest of the Python world and allow easier code interchange. See the Python section of the Coding Style Guide for specifics.
- Ballistica's APIs have been reshuffled a bit and split into several Python packages containing a hierarchy of smaller, more maintainable modules. See the Python Package Overview section below for details.
Testing
ballistica.net • discord • blog • support