Scene-Dash v2

Scene-Dash v2: the combat sample

An ECS gameplay layer for flutter_scene: a runtime for gameplay state, testable with nothing rendering.

This is the pure-Dart core: the ECS runtime and TestGame, no Flutter dependency. The scene bridge and widgets are in scene_dash_v2, which re-exports this package.

  • Entities, components, queries plain classes, deferred structural changes
  • Systems and schedules plain functions, ordered by sets and run conditions
  • Events, observers, resources decoupled communication and shared state
  • States, machines, routines game states, per-entity modes, ordered flows
  • Time frame and fixed clocks, timers, schedule-aware dt
  • Input buttons, axes, buffered presses as resources
  • Headless testing the real schedule with no scene and no GPU

A game and its test

import 'package:scene_dash_v2_core/scene_dash_v2_core.dart';

final class Runner {                           // a component
  double distance = 0;
  final double speed;
  Runner(this.speed);
}

final class Finished {                         // an event
  const Finished(this.entity);
  final Entity entity;
}

void installRace(GameBuilder game) {           // a feature
  game.addSystem(Schedules.fixedUpdate, run, writes: {Runner});
}

void run(World world) {                        // a system
  world.query<Runner>().each((entity, runner) {
    runner.distance += runner.speed * world.dt;
    if (runner.distance >= 10) world.emit(Finished(entity));
  });
}
final game = TestGame.headless(features: [installRace]);
final runner = game.world.spawn([Runner(5)]);

game.pumpFixed(steps: 60);                     // one second at 60 Hz
expect(game.world.get<Runner>(runner).distance, closeTo(5, 1e-9));

Docs

Libraries

advanced
Internal ECS APIs.
scene_dash_v2_core
Core ECS APIs.