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:
@@ -115,5 +115,22 @@ void main() {
|
||||
expect(player.bonusFlash, lessThan(1.0));
|
||||
expect(player.bonusFlash, greaterThan(0.0));
|
||||
});
|
||||
|
||||
test('weapon switch animates at canonical tic pacing', () {
|
||||
final player = Player(x: 1.5, y: 1.5, angle: 0);
|
||||
player.weapons[WeaponType.machineGun] = MachineGun();
|
||||
|
||||
player.requestWeaponSwitch(WeaponType.machineGun);
|
||||
expect(player.switchState, WeaponSwitchState.lowering);
|
||||
|
||||
player.tick(const Duration(milliseconds: 86));
|
||||
expect(player.switchState, WeaponSwitchState.raising);
|
||||
expect(player.weaponAnimOffset, closeTo(500.0, 0.001));
|
||||
expect(player.currentWeapon.type, WeaponType.machineGun);
|
||||
|
||||
player.tick(const Duration(milliseconds: 86));
|
||||
expect(player.switchState, WeaponSwitchState.idle);
|
||||
expect(player.weaponAnimOffset, closeTo(0.0, 0.001));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user