3D games in Flutter, written in Dart
Fynkel gives you Unity's way of building a game, all in code, and a Rust engine that draws it inside your Flutter app.
Drawn by Fynkel, not mocked up: the code is cut short to fit, and the whole scene is one Dart file. The knight is by Kay Lousberg (CC0).
If you know Unity, you can read this
Objects, components and onUpdate, as Dart classes. There is no editor and no scene file: the game reads, diffs and refactors like the rest of your app, and hot reload works while it runs.
void main() => runApp(FynkelApp(Hello.new));
class Hello extends GameObject { @override void onLoad() { super.onLoad(); add(GameObject( transform: Transform(position: Vec3(0, 0, 4)), components: [Camera()], )); add(Cube()); }}
class Cube extends GameObject { Cube() : super(components: [ MeshRenderer(Mesh.cube(), Material(color: Color(0xFFE0613A))), ]);
@override void onUpdate() { super.onUpdate(); rotate(Vec3.up, time.delta); }}One scene, four styles
The knight, the rogue and the light's direction stay as they are; only shaders, outlines, effects and brightness change. Shaders are small WGSL files of your own, and they hot reload.
The menu is Flutter. So is the score.
The game is one widget. Put it in a Stack, a route or half a screen, and build the menus, the score and the shop around it with the widgets you already use.
This is Pocket Hole, one of the examples, in the iPhone simulator.
Test a whole game without a window
Press keys, run seconds and check where things are, frame by frame, in flutter test. You can compare pictures too: the film above was made by a test.
test('D walks right', () { final world = World(); addTearDown(world.dispose); final walker = world.add(Walker());
world.input.simulate.keyDown(KeyCode.d); world.run(1); // a second at 60 fps
expect(walker.position.x, closeTo(4, 0.1));});What's in it
- Rendering
- wgpu on Metal and Vulkan: physically based materials, cascaded shadows, light from the sky, fog, skinned animation
- Physics
- Rapier behind Unity's names: rigidbodies, colliders, triggers, joints, a character controller
- Sound
- Sources, a listener, music and mixer groups
- Flutter
- Widgets that follow objects in the world, an on-screen stick, settings for controls, and a pause when the app is hidden
- Input
- Keys, mouse and touch, with keys the player can rebind
- Platforms
- macOS, iOS and Android, built on a Mac
Start with four lines
dart pub global activate fynkel_clifynkel create my_gamecd my_gameflutter run -d macos