From 1da5d508fac44ba69eebc87f53a4be27e3e27335 Mon Sep 17 00:00:00 2001 From: smoogipooo Date: Fri, 2 Jun 2017 11:35:51 +0900 Subject: [PATCH] aaaaa --- .../Tests/TestCaseManiaPlayfield.cs | 59 +++++++++++++------ .../Drawables/DrawableGravityTimingChange.cs | 24 ++++++-- 2 files changed, 60 insertions(+), 23 deletions(-) diff --git a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs index ea6548d296..d90cc2be71 100644 --- a/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs +++ b/osu.Desktop.VisualTests/Tests/TestCaseManiaPlayfield.cs @@ -16,6 +16,7 @@ using OpenTK.Input; using osu.Framework.Timing; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Game.Rulesets.Mania.Timing.Drawables; +using System.Linq; namespace osu.Desktop.VisualTests.Tests { @@ -54,7 +55,7 @@ namespace osu.Desktop.VisualTests.Tests Scale = new Vector2(1, -1) }); - playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); + playField.Columns.ForEach(c => c.Add(new DrawableGravityTimingChange(new TimingChange { BeatLength = 200 }))); for (int i = 0; i < cols; i++) { @@ -81,16 +82,26 @@ namespace osu.Desktop.VisualTests.Tests Clock = new FramedClock(rateAdjustClock) }); - playField.Columns.ForEach(c => c.Add(new DrawableScrollingTimingChange(new TimingChange { BeatLength = 200 }))); - for (int t = 1000; t <= 2000; t += 100) { + playField.Columns.ElementAt(0).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = t + })); + playField.Add(new DrawableNote(new Note { StartTime = t, Column = 0 }, new Bindable(Key.D))); + playField.Columns.ElementAt(3).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = t + })); + playField.Add(new DrawableNote(new Note { StartTime = t, @@ -98,6 +109,12 @@ namespace osu.Desktop.VisualTests.Tests }, new Bindable(Key.K))); } + playField.Columns.ElementAt(1).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = 1000 + })); + playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, @@ -105,6 +122,12 @@ namespace osu.Desktop.VisualTests.Tests Column = 1 }, new Bindable(Key.F))); + playField.Columns.ElementAt(2).Add(new DrawableGravityTimingChange(new TimingChange + { + BeatLength = 200, + Time = 1000 + })); + playField.Add(new DrawableHoldNote(new HoldNote { StartTime = 1000, @@ -113,23 +136,23 @@ namespace osu.Desktop.VisualTests.Tests }, new Bindable(Key.J))); }; - AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); - AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); - AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); - AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); - AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); - AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); - AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); - AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); + // AddStep("1 column", () => createPlayfield(1, SpecialColumnPosition.Normal)); + // AddStep("4 columns", () => createPlayfield(4, SpecialColumnPosition.Normal)); + // AddStep("Left special style", () => createPlayfield(4, SpecialColumnPosition.Left)); + // AddStep("Right special style", () => createPlayfield(4, SpecialColumnPosition.Right)); + // AddStep("5 columns", () => createPlayfield(5, SpecialColumnPosition.Normal)); + // AddStep("8 columns", () => createPlayfield(8, SpecialColumnPosition.Normal)); + // AddStep("Left special style", () => createPlayfield(8, SpecialColumnPosition.Left)); + // AddStep("Right special style", () => createPlayfield(8, SpecialColumnPosition.Right)); - AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); + // AddStep("Normal special style", () => createPlayfield(4, SpecialColumnPosition.Normal)); - AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); - AddWaitStep(10); - AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); - AddWaitStep(10); - AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); - AddWaitStep(10); + // AddStep("Notes", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Normal)); + // AddWaitStep(10); + // AddStep("Left special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Left)); + // AddWaitStep(10); + // AddStep("Right special style", () => createPlayfieldWithNotes(4, SpecialColumnPosition.Right)); + // AddWaitStep(10); AddStep("Notes with input", () => createPlayfieldWithNotesAcceptingInput()); } diff --git a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs index cb7a290cd2..3213ff650b 100644 --- a/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs +++ b/osu.Game.Rulesets.Mania/Timing/Drawables/DrawableGravityTimingChange.cs @@ -1,25 +1,39 @@ +using System; +using osu.Framework.Graphics; +using osu.Framework.MathUtils; using osu.Framework.Physics; +using osu.Game.Rulesets.Objects.Drawables; namespace osu.Game.Rulesets.Mania.Timing.Drawables { public class DrawableGravityTimingChange : DrawableTimingChange { - private const float acceleration = 9.8f; - private const float terminal_velocity = 50f; + private const double acceleration = 9.8f; + private const double terminal_velocity = 50f; + + private const double duration = 2000; - private RigidBodySimulation sim; public DrawableGravityTimingChange(TimingChange timingChange) : base(timingChange) { - sim = new RigidBodySimulation(Content); } protected override void Update() { base.Update(); - // Todo: Gravity calculations here + var parent = (TimingChangeContainer)Parent; + + double elapsed = Math.Max(0, Time.Current - TimingChange.Time); + + // @ Current == TimingChange.Time - duration -> Y = TimingChange.Time + // @ Current == TimingChange.Time -> Y = 0 + // @ Current == TimingChange.Time + x -> Y = -f(x) + + double acceleration = elapsed / 2 / 1000 / 1000; + + Content.Y = (float)(TimingChange.Time - 1 / 2f * acceleration * elapsed * elapsed); } } } \ No newline at end of file