Unified game screen and abstracted input
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -53,6 +53,7 @@ void main() async {
|
||||
difficulty: Difficulty.bringEmOn,
|
||||
startingEpisode: 0,
|
||||
audio: cliAudio,
|
||||
input: input,
|
||||
onGameWon: () {
|
||||
exitCleanly(0);
|
||||
print("YOU WON!");
|
||||
@@ -108,7 +109,7 @@ void main() async {
|
||||
|
||||
input.update();
|
||||
|
||||
engine.tick(elapsed, input.currentInput);
|
||||
engine.tick(elapsed);
|
||||
rasterizer.render(engine, buffer);
|
||||
rasterizer.finalizeFrame();
|
||||
|
||||
|
||||
@@ -32,12 +32,6 @@ class _DifficultyScreenState extends State<DifficultyScreen> {
|
||||
startingEpisode: Wolf3d.I.activeEpisode,
|
||||
audio: Wolf3d.I.audio,
|
||||
),
|
||||
// builder: (_) => WolfFlutterRenderer(
|
||||
// Wolf3d.I.activeGame,
|
||||
// difficulty: difficulty,
|
||||
// startingEpisode: Wolf3d.I.activeEpisode,
|
||||
// audio: Wolf3d.I.audio,
|
||||
// ),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user