Skip to content

Commit

Permalink
Make Hold animation code more intuitive
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Oct 31, 2023
1 parent 9f2f6db commit f1db2e5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
13 changes: 8 additions & 5 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableHold.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,17 @@ protected override void UpdateInitialTransforms()
{
// This is the movable length (not including start position)
const float total_movable_distance = SentakkiPlayfield.INTERSECTDISTANCE - SentakkiPlayfield.NOTESTARTDISTANCE;

// This is the amount of stretch needed. Capped to the max stretch amount.
float stretchAmount = Math.Clamp((float)(total_movable_distance / animTime * (HitObject as IHasDuration).Duration), 0, total_movable_distance);

// This is the amount of time that the note spends stretching or unstretching
float stretchTime = (float)(stretchAmount / total_movable_distance * animTime);

NoteBody.ResizeHeightTo(stretchAmount, stretchTime)
.Delay((HitObject as IHasDuration).Duration)
.MoveToY(-SentakkiPlayfield.INTERSECTDISTANCE, animTime)
.Delay(animTime - stretchTime)
.ResizeHeightTo(0, stretchTime);
NoteBody.MoveToY(-SentakkiPlayfield.INTERSECTDISTANCE, animTime) // Move the head towards the ring
.ResizeHeightTo(stretchAmount, stretchTime) // While we are moving, we stretch the hold note to match desired length
.Then().Delay(HitObject.Duration - stretchTime) // Wait until the end of the hold note, while considering how much time we need for shrinking
.ResizeHeightTo(0, stretchTime); // We shrink the hold note as it exits

if (HoldStartTime == null && !Auto)
NoteBody.Delay(animTime).FadeColour(Color4.Gray, 100);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public HoldBody()
Scale = Vector2.Zero;
Position = new Vector2(0, -SentakkiPlayfield.NOTESTARTDISTANCE);
Anchor = Anchor.Centre;
Origin = Anchor.BottomCentre;
Origin = Anchor.TopCentre;
InternalChildren = new Drawable[]
{
new NoteRingPiece(),
Expand Down

0 comments on commit f1db2e5

Please sign in to comment.