sour is a complete Cube 2: Sauerbraten experience in the web delivered as a single Docker image. Give it a try.
Some years ago I came across BananaBread, which was a basic tech demo that used Emscripten to compile Sauerbraten for the web. The project was limited in scope and done at a time when bandwidth was a lot more precious. It also lacked multiplayer out of the box.
My goal was to ship an updated version of it in a single Docker image that I could deploy anywhere and play without forcing anyone to download the whole game. That's where sour comes in.
The Sauerbraten community is small and it will probably always remain that way. There are a few main goals for this project:
- Make it easier to play Sauerbraten. Web technologies and bandwidth have gotten to the point where it is practical and desirable to play Sauerbraten in the browser.
- Mimic the experience of playing the original game as closely as possible. While it is possible that Sour may someday support arbitrary game modes, assets, clients, and server code, the vanilla game experience should still be available.
- Deployment of Sour on your own infrastructure with whatever configuration you like should be easy. Every aspect of Sour should be configurable.
docker run --rm -it -p 1234:1234 ghcr.io/cfoust/sour
You can then access Sour at http://localhost:1234/.
Note: The public Docker image only ships with the complex and xenon maps for now. While Sour supports all of Sauerbraten's maps, images that include all of them are very big. Your mileage may vary.
If you wish to deploy Sour more seriously, I provide an example configuration for docker-compose here using letsencrypt-nginx-sidecar.
Here is a high level description of the repository's directory structure:
services/game/cube2: A fork of BananaBread, which was kripken's initial attempt at getting a version of Sauerbraten running using Emscripten. He forked Sauerbraten at the mainline r4059, I upgraded to r4349, then finally upgraded to the latest mainline at the time r6519. My fork contains a handful of modifications and restrictions to make sure it can run well in the web.services/game/assets: A checkout of Sauerbraten'spackages/directory, which contains all of the game's default assets. This directory also includes Sour's asset bundling mechanism to generate prepackaged Emscripten file bundles for each game map.services/go/: Contains a Go service that periodically fetches Sauerbraten server information from the master server, pings all of the available servers, and makes that information available to the web client.services/ingress/:nginxconfigurations for development, production, and Gitpod.services/server/: A fork of QServCollect, which is a dedicated Sauerbraten server.services/proxy/: A fork of wsproxy which I changed to only allow proxying from TCP28785to UDP28786. This was the quickest way I found to get client/server communication working, though presumably you could just do this in a Python script.services/client/: A React web application that glues together the compiled Sauerbraten code and our asset fetching mechanism.
The easiest way to hack on Sour is in Gitpod using the button below. Gitpod is a web-based VSCode environment that runs everything necessary for development in a cloud-based container, meaning that everything is set up and working for you right away. You do not even have to use VSCode; Gitpod supports custom dotfiles which allows me to use my full vim-based setup from a browser tab.
If you want to run things locally (some people are old fashioned that way) all you need is Docker, Earthly, and docker-compose. After that, just run ./serve. Then navigate to http://localhost:1234. All of the game's services will recompile and restart when you make changes.
Check out the roadmap below to see what you might be able to help with.
- Better documentation
- Create a README for each directory in
services/ - Describe how asset generation works
- Create a README for each directory in
- Add
<noscript>with a plea to enable JavaScript - Ensure Sour works in Firefox
- Allow for providing the desired maps in an image as a build argument
- Full Terraform support for deploying Sour
- Alow parts of Sour to be configured with a high-level configuration file
- Investigate differences in font colors between the real Sauer and Sour
- Remove base game assets from the repository
- Clean loading page for slow connections (ensure page load time isn't horrible)
- Demo player with seek/play/pause
- Stretch goal: generate gifs in the browser
- Update the URL to the current server on join eg
sourga.me/server/127.0.0.1:28785 - 1v1 duel server + rankings?
- Save demos for any game played to IndexedDB and allow for download
- Allow players to create private servers with simple join links eg
sourga.me/server/ABCD - Explore running Sour in a Web Worker rather than the rendering thread
- Support all player models (right now it's just snout)
- Modern, beautiful main menu
- Create archive of all uploads to Quadropolis
- Allow for loading of arbitrary archives from Quadropolis
- Repair or port shaders that were disabled in the game upgrade
- Fix the outline shader (pressing 7 in edit mode)
- Support saving and loading
.ogzmaps from the user's device
Each project that was forked into this repository has its own original license intact, though the glue code and subsequent modifications I have made are licensed according to the MIT license specified in LICENSE.