SpringCabal games run on Rust now
I have ported all SpringCabal games to Rust WASM. This is what all my future Spring games and other projects will be written in.
This blog post is the first in a series featuring the Native & WASM capabilities I have added to the Spring engine. It’s the first time I’m publicly showcasing work in this area, and I plan to write a few more posts on the subject over the coming months.
SpringCabal
For some background, SpringCabal games were built for the Ludum Dare game jam, from 2015 to 2018, for a total of seven games. The team consisted of experienced Spring developers, as well as family and friends who were pretty new to gamedev in general. There wasn’t a fixed core team in any sense, even though a few members were frequent participants, and as team size varied quite a bit from jam to jam, so did the quality and scope of the games.
Spring is good for making RTS games. Stubbornly, SpringCabal, barring one entry, refused to make any: we already knew those work. Most of our games were variations of third person action games, often controlled by WASD keys + mouse and a camera that would follow the player. This involved a bit of effort to wrestle with an engine built for a different purpose, and would’ve probably been trivial to do in Unity, Unreal or Godot, even back then.
I generally enjoyed making these games, and I thought it was a bit unfortunate that you couldn’t play most of them anymore. They didn’t run on the latest engine - the 10y gap meant there were some incompatibilities, and their old distributed version didn’t run either, the glibc version (or whatever?) the engine relied on was out of date, so they lived on only in distant memory and Shadowfury’s YouTube clips (Gravitas, Zeus vs Bunnies, Area17, Flove, Parts Needed). For some games, I had to refer to the videos as I have honestly forgotten how the games played or what exactly they looked like.
Port process
I took the original Lua games, and first ensured they were compatible with the new engine, doing one game at a time, and fixing each issue in a clean, focused commit, carefully reviewing each change to make sure I have good foundations… is what the “proper” approach would’ve been.
However, I was rather impatient so I had a bunch of cheap AI agents work on both Lua fixes and Rust ports in parallel, for many games at the same time, while I mostly tested the game, guided high level technical decisions and pointed AI to the right direction when it got stuck (there’s something really fun in correctly guessing where the source of convoluted bugs is without even looking at the code).
Unsurprisingly, I had to apply the same set of fixes to both Lua and Rust, and games were usually broken in the same way (engine compatibility issues tend to be common). This approach was honestly quite fun as I got to see things in action & play test a lot. AIs would also build things differently, so I could pick and choose the best of their approaches, even though I ended up doing 2~3 large refactors later down the line when I actually read the code.
I don’t like talking about AI much, as that’s what most articles seem to be about these days, but I’d like to give an idea of how long it took me to build this:
- I started working on the core Native interface somewhere at the end of last year. I wrote most of the binding interface C++ there myself, only using AI for function level-translation, for which a slightly advanced awk or python script could get you 90% of the way there.
- After I verified my foundations worked, I started doing mass conversion of the entire 1000+ function API. After I decided on the base data layout, the actual work was done entirely by AI, over the course of multiple months. In a way it served as a token/usage dump as well: when I had nothing better for it to do, I’d have it port the missing functions, build & run Lua~Native parity checks, re-analyze the implementation, find something it might’ve missed and so on. During that time it found a few bugs in upstream Recoil (particularly in RmlUi), some of which I’ve started to backport upstream (and this takes a bit extra time to properly structure for human consumption).
- I added WASM on top of the native interface, first as part of the component model, and then later converted in to WASM core mostly for performance reasons, somewhere in August this year (this entire process took only a few days as it was laid nicely on top of existing native interface), but despite being “done”, much of the binding was still missing, incomplete or incorrect, so these SpringCabal games served as a way to find and fill the gaps.
- The actual Rust port of the SpringCabal games took maybe a day to get to a “Somewhat Working” state, three or so days to get it “Mostly Working” and then perhaps an additional week to get it to the original Lua quality and in some cases improve upon it - with somewhat decent code & architecture (the originals were game jams built over a weekend, so I didn’t hold myself to a much higher standard). During this time quite a bit of work went into fixing the new WASM bindings and building various frameworks (crates) that would seem familiar to experienced Spring devs and provide a smoother dev experience overall.
These games feature a new in-game Rust/WASM menu as well, which is also written with RmlUi (first of its kind?), something that this new engine also adds for the Menu environment of the engine (last I checked, in the current Recoil engine, RmlUi doesn’t run in the LuaMenu environment). There are some limitations to using a sandboxed WASM here (a topic for a later article), but it was perfectly fine for these purposes.
Games
All games are packaged as a single archive which includes both Rust and Lua versions of all 7 games (and their maps), the engine and the above mentioned menu.
You can find the latest releases here, which at the time of this writing (1.0.2) are:
After extracting, you can run the “SpringCabal” executable (renamed spring binary), which launches the WASM menu. First boot might take a few seconds for it to scan all archives & cache things like fontconfig.
Sources:
- Engine: rust-wip
- Games (each has a “rust” branch):
- Menu + local dev environment: springcabal-dev
Future
This is a fairly large piece of work, and I’m in no particular rush to merge this into upstream Recoil. It’s not ready yet. As I mentioned in the opening, in the next few months, I plan to write a few more articles about this, to cover various technical topics and challenges. This might help bridge understanding of the work itself and help me polish it a bit further as I lay out my ideas.
The space game I’m making (name pending), which some of you might’ve seen, is, barring a few defs, built entirely in Rust. I’m hoping the time I spend there (working on some rather interesting optimization problems right now) will help further strengthen the core foundations here.
To give a rough timeline, my optimistic view is that I might start the process of opening the first PRs into the upstream engine somewhere at the end of this year. Obviously it’s all open source and you can try it today.
I don’t want to step on any toes, so I have no intention of porting any other existing game - unless the developers are interested - in which case, please reach out. I’d estimate it would take about 1 week to port something like ZK or BAR to Rust, in a “Mostly Working” state, but the AI produced slop would be tremendous and rightly annoy most contributors, and I don’t think this is how open source projects should be handled. If and when such a port would occur, I recommend taking a slower approach, especially in the beginning, ideally showing the various benefits this might bring. Hopefully SpringCabal games can serve as a showcase of how to properly structure this.