1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Change SpinFramesGenerator to take degrees as input

This commit is contained in:
Dean Herbert 2023-10-16 18:34:56 +09:00
parent 28ee99f132
commit 04af46b8c7
No known key found for this signature in database
5 changed files with 24 additions and 24 deletions

View File

@ -39,12 +39,12 @@ namespace osu.Game.Rulesets.Osu.Tests
/// <summary> /// <summary>
/// Performs a single spin. /// Performs a single spin.
/// </summary> /// </summary>
/// <param name="delta">The amount, relative to a full circle, to spin.</param> /// <param name="delta">The amount of degrees to spin.</param>
/// <param name="duration">The time to spend to perform the spin.</param> /// <param name="duration">The time to spend to perform the spin.</param>
/// <returns>This <see cref="SpinFramesGenerator"/>.</returns> /// <returns>This <see cref="SpinFramesGenerator"/>.</returns>
public SpinFramesGenerator Spin(float delta, double duration) public SpinFramesGenerator Spin(float delta, double duration)
{ {
sequences.Add((delta * 2 * MathF.PI, duration)); sequences.Add((delta / 360 * 2 * MathF.PI, duration));
return this; return this;
} }

View File

@ -362,7 +362,7 @@ namespace osu.Game.Rulesets.Osu.Tests
}; };
frames.AddRange(new SpinFramesGenerator(time_spinner + 10) frames.AddRange(new SpinFramesGenerator(time_spinner + 10)
.Spin(1, 500) .Spin(360, 500)
.Build()); .Build());
performTest(hitObjects, frames); performTest(hitObjects, frames);

View File

@ -107,14 +107,14 @@ namespace osu.Game.Rulesets.Osu.Tests
/// <summary> /// <summary>
/// Spins in a single direction. /// Spins in a single direction.
/// </summary> /// </summary>
[TestCase(0.5f, 0)] [TestCase(180, 0)]
[TestCase(-0.5f, 0)] [TestCase(-180, 0)]
[TestCase(1, 1)] [TestCase(360, 1)]
[TestCase(-1, 1)] [TestCase(-360, 1)]
[TestCase(1.5f, 1)] [TestCase(540, 1)]
[TestCase(-1.5f, 1)] [TestCase(-540, 1)]
[TestCase(2f, 2)] [TestCase(720, 2)]
[TestCase(-2f, 2)] [TestCase(-720, 2)]
public void TestSpinSingleDirection(float amount, int expectedTicks) public void TestSpinSingleDirection(float amount, int expectedTicks)
{ {
performTest(new SpinFramesGenerator(time_spinner_start) performTest(new SpinFramesGenerator(time_spinner_start)
@ -134,8 +134,8 @@ namespace osu.Game.Rulesets.Osu.Tests
public void TestSpinHalfBothDirections() public void TestSpinHalfBothDirections()
{ {
performTest(new SpinFramesGenerator(time_spinner_start) performTest(new SpinFramesGenerator(time_spinner_start)
.Spin(0.5f, 500) // Rotate to +0.5. .Spin(180, 500) // Rotate to +0.5.
.Spin(-1f, 500) // Rotate to -0.5 .Spin(-360, 500) // Rotate to -0.5
.Build()); .Build());
assertTicksHit(0); assertTicksHit(0);
@ -145,10 +145,10 @@ namespace osu.Game.Rulesets.Osu.Tests
/// <summary> /// <summary>
/// Spin in one direction then spin in the other. /// Spin in one direction then spin in the other.
/// </summary> /// </summary>
[TestCase(0.5f, -1.5f, 1)] [TestCase(180, -540, 1)]
[TestCase(-0.5f, 1.5f, 1)] [TestCase(-180, 540, 1)]
[TestCase(0.5f, -2.5f, 2)] [TestCase(180, -900, 2)]
[TestCase(-0.5f, 2.5f, 2)] [TestCase(-180, 900, 2)]
[Ignore("An upcoming implementation will fix this case")] [Ignore("An upcoming implementation will fix this case")]
public void TestSpinOneDirectionThenChangeDirection(float direction1, float direction2, int expectedTicks) public void TestSpinOneDirectionThenChangeDirection(float direction1, float direction2, int expectedTicks)
{ {
@ -168,11 +168,11 @@ namespace osu.Game.Rulesets.Osu.Tests
AddStep("set manual clock", () => manualClock = new ManualClock { Rate = 1 }); AddStep("set manual clock", () => manualClock = new ManualClock { Rate = 1 });
List<ReplayFrame> frames = new SpinFramesGenerator(time_spinner_start) List<ReplayFrame> frames = new SpinFramesGenerator(time_spinner_start)
.Spin(1f, 500) // 2000ms -> 1 full CW spin .Spin(360, 500) // 2000ms -> 1 full CW spin
.Spin(-0.5f, 500) // 2500ms -> 0.5 CCW spins .Spin(-180, 500) // 2500ms -> 0.5 CCW spins
.Spin(0.25f, 500) // 3000ms -> 0.25 CW spins .Spin(90, 500) // 3000ms -> 0.25 CW spins
.Spin(1.25f, 500) // 3500ms -> 1 full CW spin .Spin(450, 500) // 3500ms -> 1 full CW spin
.Spin(0.5f, 500) // 4000ms -> 0.5 CW spins .Spin(180, 500) // 4000ms -> 0.5 CW spins
.Build(); .Build();
loadPlayer(frames); loadPlayer(frames);

View File

@ -57,7 +57,7 @@ namespace osu.Game.Rulesets.Osu.Tests
} }
private static List<ReplayFrame> generateReplay(int spins) => new SpinFramesGenerator(time_spinner_start) private static List<ReplayFrame> generateReplay(int spins) => new SpinFramesGenerator(time_spinner_start)
.Spin(spins, time_spinner_end - time_spinner_start) .Spin(spins * 360, time_spinner_end - time_spinner_start)
.Build(); .Build();
private void performTest(List<ReplayFrame> frames) private void performTest(List<ReplayFrame> frames)

View File

@ -290,7 +290,7 @@ namespace osu.Game.Rulesets.Osu.Tests
}; };
frames.AddRange(new SpinFramesGenerator(time_spinner + 10) frames.AddRange(new SpinFramesGenerator(time_spinner + 10)
.Spin(1, 500) .Spin(360, 500)
.Build()); .Build());
performTest(hitObjects, frames); performTest(hitObjects, frames);