How 1111windows/supertux works
SuperTux is a C++ game engine plus content bundle, not just a single executable. The runtime is organized around a core engine in src/ and a large, data-driven game world under data/ containing levels, sprites, sounds, music, translations, and scripts.
1. Entry point and top-level orchestration
Execution starts in src/main.cpp and src/supertux/main.cpp, then hands off to the game/session and screen management layer. The central control flow is screen-based: screen_manager, game_manager, and game_session coordinate transitions between title screen, menus, level play, world map, editor, cutscenes, and other modes.
2. Game state and level runtime
The core runtime model lives in src/supertux/. level, sector, world, levelset, player_status, savegame, and statistics represent the playable state. Level loading is parser-driven (level_parser, sector_parser, worldmap_sector_parser) and converts files in data/levels/** into runtime objects.
3. Object and entity system
Gameplay is built from a large object hierarchy in src/object/, src/badguy/, and src/trigger/. These cover the player, enemies, interactive blocks, particles, triggers, doors, switches, platforms, and scripted objects. game_object_factory and object_factory are the main construction boundaries between parsed content and instantiated gameplay entities.
4. Physics and collision boundary
Movement and interaction are handled by src/physic/ and src/collision/. The collision system is separated from rendering and scripting, with movement managers, collision objects, and collision groups mediating how players, enemies, blocks, and triggers physically interact.
5. Rendering pipeline
Graphics are abstracted through src/video/, which provides a renderer/video-system boundary with multiple backends: SDL-based, OpenGL-based, and a null backend for non-graphical contexts. Fonts, textures, surfaces, compositing, and viewport management are all separate layers, so game logic does not depend directly on a particular graphics API.
6. Input and controller handling
Input is centralized in src/control/. Keyboard, joystick/gamepad, mobile, and code-driven controls are normalized through input_manager, controller abstractions, and per-device configs. This feeds the gameplay and menu systems through a common control layer.
7. Audio subsystem
src/audio/ wraps sound files and playback with backend-specific sources. The repo includes OpenAL-backed playback plus dummy/streaming implementations, and supports WAV and OGG assets from data/sounds/, data/music/, and data/speech/.
8. Scripting and extensibility
SuperTux uses Squirrel for gameplay and menu scripting. src/squirrel/ provides the VM, scheduler, thread queue, serialization, and API bridge (supertux_api). Game content also includes .nut scripts in level folders and global scripts in data/scripts/.
9. Menus, UI, and in-game tools
Menu and UI logic is split between src/gui/, src/interface/, and src/supertux/menu/. These layers drive the title menu, options, language selection, add-on browser, cheat menus, and editor menus. The level editor is embedded in the same codebase under src/editor/ and uses the same resource and object systems as gameplay.
10. World map and campaign structure
World-map gameplay is a distinct subsystem in src/worldmap/. It has its own camera, movement, teleports, level tiles, and state machine, and it reads *.stwm worldmap files from data/levels/**. This is separate from in-level sector gameplay, but shares resources, scripting, and presentation infrastructure.
11. Assets, localization, and filesystem access
Game content is organized under data/ by asset type: images, sprites, tilesets, fonts, levels, locale files, shaders, sounds, and music. File access is abstracted through src/physfs/ and src/util/file_system.hpp, which allows packaged assets, mods, and add-ons to be mounted consistently. Translations use gettext (src/util/gettext.cpp, tinygettext, data/locale/*.po).
12. Add-ons and external services
src/addon/ handles downloadable content, add-on metadata, and installation; there is also an SDK integration layer in src/sdk/ including Discord presence. This forms the network-facing boundary of the project, distinct from the offline core game loop.
13. Build and platform packaging
The project is built with CMake and a large set of platform-specific scripts and workflows. There are dedicated paths for Android, Emscripten/WebAssembly, Flatpak, Windows, macOS, GNU/Linux, and FreeBSD, plus bundled third-party libraries in external/. This matters architecturally because the same engine is compiled into multiple deployment targets with different frontend/runtime wrappers.
14. Testing and tooling
Unit tests live under tests/unit/ and focus on core utilities, math, file system, parsing, collision, and object options. Tooling under tools/ supports level conversion, string extraction, documentation generation, asset processing, and packaging, reinforcing that most of the game is data-driven and heavily asset-processed rather than hand-coded scene graphs.
Main entry points: screen_manager.cpp Screen Flow · data Assets · level.cpp Level Runtime · player.cpp Entities
Components 19
Runtime
Core engine and gameplay flow
- Entry · Process entry and bootstrapping
src/main.cpp - App Core · Application setup and main control handoff
src/supertux/main.cpp - Screen Flow · Screen-based game flow and transitions
src/supertux/screen_manager.cpp - Game State · Persistent game, profile, and save data
src/supertux/game_session.cpp - Level Runtime · Levels, sectors, world map, and parsers
src/supertux/level.cpp - Factory · Creates gameplay objects from parsed content
src/supertux/game_object_factory.cpp - Entities · Player, enemies, blocks, triggers, and objects
src/object/player.cpp - Physics · Movement and collision coordination
src/supertux/physic.cpp - Collision · Collision objects, groups, and resolution
src/collision/collision_system.cpp - Video · Renderer abstraction and backend implementations
src/video/video_system.cpp - Input · Keyboard, joystick, mobile, and code-driven input
src/control/input_manager.cpp - Audio · Sound file loading and playback backends
src/audio/sound_manager.cpp - Scripting · Squirrel runtime and API bridge
src/squirrel/squirrel_virtual_machine.cpp - UI & Menus · Menus, dialogs, interface widgets, and editor tooling
src/supertux/menu/main_menu.cpp - World Map · Campaign world-map gameplay and parsing
src/worldmap/worldmap.cpp - Filesystem · Virtual filesystem, PhysFS wrappers, gettext, and file utilities
src/physfs/physfs_file_system.cpp - Add-ons · Downloadable content and integration services
src/addon/addon_manager.cpp
Content
Data-driven assets and level content
- Assets · Images, sounds, music, levels, locale, shaders, and scripts
data
Platform
Build, packaging, and external dependencies
- Build & Ports · CMake, platform packaging, external libraries, and tooling
CMakeLists.txt
Connections 19
- Entry → App Core: boots · Program startup enters the application layer
- App Core → Screen Flow: drives · Application hands control to the screen/state manager
- Screen Flow → Game State: uses · Screen flow reads and mutates session state
- Screen Flow → UI & Menus: opens · Menus and editor screens are managed as screens
- Screen Flow → Level Runtime: switches to · Gameplay screens load levels and world maps
- Level Runtime → Factory: instantiates · Parsed level content becomes runtime objects
- Factory → Entities: creates · Factory materializes gameplay entities
- Entities → Physics: moves via · Objects rely on movement and physics helpers
- Physics → Collision: queries · Movement is constrained by collision resolution
- Level Runtime → Scripting: runs · Level and world content can invoke Squirrel scripts
- UI & Menus → Input: consumes · Menus, editor, and in-game tools respond to normalized input
- UI & Menus → Video: draws via · UI is rendered through the video abstraction
- Entities → Video: draws via · Game objects use the rendering pipeline for sprites and effects
- Audio → Assets: loads · Playback sources consume sound and music assets
- Video → Assets: loads · Textures, fonts, shaders, and images come from data files
- Scripting → Assets: executes · Scripts live in the data bundle alongside levels
- Filesystem → Assets: mounts · Filesystem layer exposes packaged content and mods
- Add-ons → Filesystem: installs through · Add-ons are fetched and installed through the filesystem boundary
- Build & Ports → Entry: packages · Build and port infrastructure produce the runtime binaries