Unified game screen and abstracted input
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -3,6 +3,7 @@ import 'dart:math' as math;
|
||||
import 'package:wolf_3d_data_types/wolf_3d_data_types.dart';
|
||||
import 'package:wolf_3d_engine/wolf_3d_engine.dart';
|
||||
import 'package:wolf_3d_entities/wolf_3d_entities.dart';
|
||||
import 'package:wolf_3d_input/wolf_3d_input.dart';
|
||||
|
||||
class WolfEngine {
|
||||
WolfEngine({
|
||||
@@ -11,6 +12,7 @@ class WolfEngine {
|
||||
required this.startingEpisode,
|
||||
required this.onGameWon,
|
||||
required this.audio,
|
||||
required this.input,
|
||||
}) : doorManager = DoorManager(
|
||||
onPlaySound: (sfxId) => audio.playSoundEffect(sfxId),
|
||||
);
|
||||
@@ -28,6 +30,7 @@ class WolfEngine {
|
||||
|
||||
// Managers
|
||||
final DoorManager doorManager;
|
||||
final Wolf3dInput input;
|
||||
|
||||
final PushwallManager pushwallManager = PushwallManager();
|
||||
|
||||
@@ -51,12 +54,15 @@ class WolfEngine {
|
||||
}
|
||||
|
||||
// Expect standard Dart Duration. The host app is responsible for the loop.
|
||||
void tick(Duration elapsed, EngineInput input) {
|
||||
void tick(Duration elapsed) {
|
||||
if (!isInitialized) return;
|
||||
|
||||
_timeAliveMs += elapsed.inMilliseconds;
|
||||
|
||||
final inputResult = _processInputs(elapsed, input);
|
||||
input.update();
|
||||
final currentInput = input.currentInput;
|
||||
|
||||
final inputResult = _processInputs(elapsed, currentInput);
|
||||
|
||||
doorManager.update(elapsed);
|
||||
pushwallManager.update(elapsed, currentLevel);
|
||||
|
||||
Reference in New Issue
Block a user