example-firefly-trail
Firefly Trail
A small iPhone game on Garnet's app plugins. game.cr is one world plugin: the rules live in the Board resource, a Phase state gates the fixed-step firefly.step system, the trail and light are scene entities shown through a Camera2D fitted to the board area, and the title, score and Restart button are a UI::Plugin tree. ios.cr is World.new + App::IOS + world.run on the shared host (engine/native/ios/host.m); desktop.cr runs the same plugin in a window.
The board, its checkerboard, the light and the camera are laid out in scenes/board.json, which garnet edit opens in the editor's 2D view (editor.cr registers the firefly.checker component from scene.cr). The game compiles the scene in and attaches its markers to the board, light and camera nodes; the trail segments are spawned as the run goes. spec/board_scene_spec.cr moves the light in the editor and loads the saved layout.
Swipe (or press the arrow keys / WASD / D-pad) to start and steer. Collect amber lights to extend the trail. Hitting an edge or the trail ends the run. Tap Restart to set up a new run.
Build on macOS for iPhone
The app targets iOS 18 or later on ARM64, with Crystal 1.19.1, Xcode and Boehm GC 8.2.12. Text uses the system font through Core Text (Garnet::Text::SystemFont from text-system, whose native/system_font.c the app links).
git clone --depth 1 --branch v8.2.12 https://github.com/bdwgc/bdwgc.git /tmp/firefly-bdwgc
GARNET_IOS_GC_SOURCE=/tmp/firefly-bdwgc GARNET_IOS_UI_LIBS=/path/to/ui-libs \
scripts/build-ios-example firefly_trail /tmp/firefly-build
Sign the bundle for your device. Launch with --smoke to replay a scripted run through App::Capture: it turns right then up, checks that a light was collected and the trail turned, and reads back the presented frame.
crystal spec engine/spec/firefly_trail_spec.cr # headless, driven by tapes
garnet run --project engine/examples/firefly_trail # desktop window
Build on Windows
From a Visual Studio 2022 Developer prompt with Crystal 1.19.1, GNU make, GLFW 3.4 (lib-vc2022 on CRYSTAL_LIBRARY_PATH) and the vcpkg ports harfbuzz[core], fribidi, libunibreak and (for the editor specs) tree-sitter (x64-windows; lib on CRYSTAL_LIBRARY_PATH, bin on PATH). Text uses Segoe UI from %WINDIR%\Fonts.
garnet build --target desktop-gl # or desktop-vulkan, with the Vulkan SDK
.garnet/build/desktop-gl-debug/FireflyTrail.exe
The windows CI job builds both targets and renders them on Mesa's llvmpipe and lavapipe.
example-firefly-trail
- 0
- 0
- 0
- 0
- 0
- about 4 hours ago
- November 30, 2026
Fri, 04 Dec 2026 20:41:05 GMT