WIP moving difficulty selection to engine
Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
@@ -14,10 +14,32 @@ class CliInput extends Wolf3dInput {
|
||||
bool _pRight = false;
|
||||
bool _pFire = false;
|
||||
bool _pInteract = false;
|
||||
bool _pBack = false;
|
||||
WeaponType? _pWeapon;
|
||||
|
||||
/// Queues a raw terminal key sequence for the next engine frame.
|
||||
void handleKey(List<int> bytes) {
|
||||
// Escape sequences for arrow keys (CSI A/B/C/D) in raw terminal mode.
|
||||
if (bytes.length >= 3 && bytes[0] == 27 && bytes[1] == 91) {
|
||||
if (bytes[2] == 65) _pForward = true; // Up
|
||||
if (bytes[2] == 66) _pBackward = true; // Down
|
||||
if (bytes[2] == 67) _pRight = true; // Right
|
||||
if (bytes[2] == 68) _pLeft = true; // Left
|
||||
return;
|
||||
}
|
||||
|
||||
// Bare Escape key is a menu back action.
|
||||
if (bytes.length == 1 && bytes[0] == 27) {
|
||||
_pBack = true;
|
||||
return;
|
||||
}
|
||||
|
||||
// Enter maps to menu select/confirm.
|
||||
if (bytes.length == 1 && (bytes[0] == 13 || bytes[0] == 10)) {
|
||||
_pInteract = true;
|
||||
return;
|
||||
}
|
||||
|
||||
String char = String.fromCharCodes(bytes).toLowerCase();
|
||||
|
||||
if (char == 'w') _pForward = true;
|
||||
@@ -45,10 +67,12 @@ class CliInput extends Wolf3dInput {
|
||||
isTurningRight = _pRight;
|
||||
isFiring = _pFire;
|
||||
isInteracting = _pInteract;
|
||||
isBack = _pBack;
|
||||
requestedWeapon = _pWeapon;
|
||||
|
||||
// Reset the pending buffer so each keypress behaves like a frame impulse.
|
||||
_pForward = _pBackward = _pLeft = _pRight = _pFire = _pInteract = false;
|
||||
_pBack = false;
|
||||
_pWeapon = null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ abstract class Wolf3dInput {
|
||||
bool isTurningLeft = false;
|
||||
bool isTurningRight = false;
|
||||
bool isInteracting = false;
|
||||
bool isBack = false;
|
||||
double? menuTapX;
|
||||
double? menuTapY;
|
||||
bool isFiring = false;
|
||||
WeaponType? requestedWeapon;
|
||||
|
||||
@@ -22,6 +25,9 @@ abstract class Wolf3dInput {
|
||||
isTurningRight: isTurningRight,
|
||||
isFiring: isFiring,
|
||||
isInteracting: isInteracting,
|
||||
isBack: isBack,
|
||||
menuTapX: menuTapX,
|
||||
menuTapY: menuTapY,
|
||||
requestedWeapon: requestedWeapon,
|
||||
);
|
||||
}
|
||||
@@ -33,6 +39,7 @@ enum WolfInputAction {
|
||||
turnRight,
|
||||
fire,
|
||||
interact,
|
||||
back,
|
||||
weapon1,
|
||||
weapon2,
|
||||
weapon3,
|
||||
|
||||
Reference in New Issue
Block a user