Unified game screen and abstracted input

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-16 16:10:12 +01:00
parent 0963869b0c
commit b702c50d30
9 changed files with 22 additions and 36 deletions

View File

@@ -27,19 +27,22 @@ class GameScreen extends StatefulWidget {
class _GameScreenState extends State<GameScreen> {
late final WolfEngine _engine;
final Wolf3dInput _inputManager = Wolf3dFlutterInput();
late final Wolf3dInput _input;
bool _useAsciiMode = false;
@override
void initState() {
super.initState();
_input = Wolf3dFlutterInput();
// The Host Screen owns the engine lifecycle
_engine = WolfEngine(
data: widget.data,
difficulty: widget.difficulty,
startingEpisode: widget.startingEpisode,
audio: widget.audio,
input: _input,
onGameWon: () => Navigator.of(context).pop(),
);
@@ -53,14 +56,8 @@ class _GameScreenState extends State<GameScreen> {
children: [
// Render the active view
_useAsciiMode
? WolfAsciiRenderer(
engine: _engine,
inputManager: _inputManager,
)
: WolfFlutterRenderer(
engine: _engine,
inputManager: _inputManager,
),
? WolfAsciiRenderer(engine: _engine)
: WolfFlutterRenderer(engine: _engine),
// Invisible listener to trap the 'Tab' key and swap renderers
Focus(