feat: Enhance weapon switching logic and add tests for animation pacing and menu behavior

Signed-off-by: Hans Kokx <hans.d.kokx@gmail.com>
This commit is contained in:
2026-03-23 12:35:31 +01:00
parent 827b8c779e
commit a66ccf52c5
6 changed files with 66 additions and 15 deletions
@@ -49,6 +49,27 @@ void main() {
expect(mapPixels.contains(ColorPalette.vga32Bit[2]), isTrue);
expect(mapPixels[hudProbeIndex], equals(normalPixels[hudProbeIndex]));
});
test('software renderer does not apply bonus flash while menu is open', () {
final input = _MutableInput();
final engine = _buildEngine(input: input);
engine.init();
input.isBack = true;
engine.tick(const Duration(milliseconds: 16));
input.isBack = false;
expect(engine.isMenuOpen, isTrue);
final renderer = SoftwareRenderer();
engine.player.bonusFlash = 0.0;
final List<int> menuBaseline = List<int>.from(renderer.render(engine).pixels);
engine.player.bonusFlash = 1.0;
final List<int> menuWithFlash = List<int>.from(renderer.render(engine).pixels);
expect(menuWithFlash, equals(menuBaseline));
});
});
}
@@ -69,7 +90,12 @@ class _StaticInput extends Wolf3dInput {
}
}
WolfEngine _buildEngine() {
class _MutableInput extends Wolf3dInput {
@override
void update() {}
}
WolfEngine _buildEngine({Wolf3dInput? input}) {
final wallGrid = _buildGrid();
final objectGrid = _buildGrid();
@@ -115,7 +141,7 @@ WolfEngine _buildEngine() {
difficulty: Difficulty.medium,
startingEpisode: 0,
frameBuffer: FrameBuffer(96, 96),
input: _StaticInput(),
input: input ?? _StaticInput(),
onGameWon: () {},
);
}