diff --git a/lib/effects/effects.dart b/lib/effects/effects.dart index bc961e03f..587fad661 100644 --- a/lib/effects/effects.dart +++ b/lib/effects/effects.dart @@ -63,7 +63,7 @@ abstract class ComponentEffect { percentage = (currentTime / travelTime).clamp(0.0, 1.0).toDouble(); curveProgress = curve.transform(percentage); _updateDriftTime(); - currentTime = currentTime.clamp(0.0, travelTime).toDouble(); + //currentTime = currentTime.clamp(0.0, travelTime).toDouble(); if (hasFinished()) { onComplete?.call(); } diff --git a/test/effects/effect_test_utils.dart b/test/effects/effect_test_utils.dart index a3025dfcd..62a6a232a 100644 --- a/test/effects/effect_test_utils.dart +++ b/test/effects/effect_test_utils.dart @@ -25,7 +25,7 @@ void effectTest( Vector2 expectedSize, // Only use when checking a value that is not in // the start, end or peak of an iteration - double floatRange = 0.000001, + double floatRange = 0.0, }) async { expectedPosition ??= Vector2.zero(); expectedSize ??= Vector2.all(100.0); @@ -38,10 +38,24 @@ void effectTest( await tester.pumpWidget(game.widget); double timeLeft = iterations * duration; while (timeLeft > 0) { - final double stepDelta = random.nextInt(100) / 1000; + double stepDelta = (50+random.nextInt(50)) / 1000; + stepDelta = stepDelta < timeLeft ? stepDelta : timeLeft; game.update(stepDelta); timeLeft -= stepDelta; } + if(effect.driftTime > 0) { + print("DRIIIIFT ${effect.driftTime} ${effect.travelTime}"); + } + expect( + effect.hasFinished(), + hasFinished, + reason: "Effect.hasFinished() didn't have the expected value", + ); + expect( + callback.isCalled, + hasFinished, + reason: 'Callback was not treated properly', + ); if (floatRange != 0) { bool acceptableVector(Vector2 vector, Vector2 expectedVector) { return (expectedVector - vector).length < floatRange; @@ -64,8 +78,6 @@ void effectTest( expect(component.angle, expectedAngle, reason: "Angle is not correct"); expect(component.size, expectedSize, reason: "Size is not correct"); } - expect(effect.hasFinished(), hasFinished); - expect(callback.isCalled, hasFinished); game.update(0.0); // Since effects are removed before they are updated expect(component.effects.isEmpty, hasFinished); } diff --git a/test/effects/move_effect_test.dart b/test/effects/move_effect_test.dart index 415353535..7fba1314c 100644 --- a/test/effects/move_effect_test.dart +++ b/test/effects/move_effect_test.dart @@ -16,7 +16,7 @@ void main() { MoveEffect effect(bool isInfinite, bool isAlternating) { return MoveEffect( path: path, - duration: random.nextDouble() * 100, + duration: random.nextInt(100).toDouble(), isInfinite: isInfinite, isAlternating: isAlternating, ); diff --git a/test/effects/rotate_effect_test.dart b/test/effects/rotate_effect_test.dart index 9ee433430..c9078e32d 100644 --- a/test/effects/rotate_effect_test.dart +++ b/test/effects/rotate_effect_test.dart @@ -21,7 +21,7 @@ void main() { RotateEffect effect(bool isInfinite, bool isAlternating) { return RotateEffect( angle: angleArgument, - duration: random.nextDouble() * 100, + duration: random.nextInt(100).toDouble(), isInfinite: isInfinite, isAlternating: isAlternating, ); diff --git a/test/effects/scale_effect_test.dart b/test/effects/scale_effect_test.dart index 083760354..41c221133 100644 --- a/test/effects/scale_effect_test.dart +++ b/test/effects/scale_effect_test.dart @@ -16,7 +16,7 @@ void main() { ScaleEffect effect(bool isInfinite, bool isAlternating) { return ScaleEffect( size: argumentSize, - duration: random.nextDouble() * 100, + duration: random.nextInt(100).toDouble(), isInfinite: isInfinite, isAlternating: isAlternating, );