Skip to content
Eric Froemling edited this page Mar 30, 2020 · 65 revisions

Overview

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).

Ballistica vs Original BombSquad

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 uses a modern version of Python (3.7 at the time of this writing), whereas the old code was using the (now end-of-life) 2.7 version. 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 from that version; no need to worry about backward 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. I apologize for the annoyance of having to rewrite lots of thisTypeOfThing() to this_type_of_thing, but if you take some time and familiarize yourself with the type-checking setup and get creative with search-and-replace then it shouldn't take too long I hope.
  • 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.

Python Package Overview

In original BombSquad, game scripts were contained in a single flat directory of (often very large) Python modules. There were getting to be a lot of these, and some of them had grown in size over time to become extremely unwieldy, so a reorganization was in order. They have now been split into much smaller, more manageable modules and organized into several Packages. These are described below.

Clone this wiki locally