Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Touch animation to better represent the hitwindow #76

Merged
merged 5 commits into from
Jul 7, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableTouch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ private void load(SentakkiRulesetConfigManager sentakkiConfigs)
}

// Easing functions for manual use.
private readonly DefaultEasingFunction inOutBack = new DefaultEasingFunction(Easing.InOutBack);
private readonly DefaultEasingFunction outSine = new DefaultEasingFunction(Easing.OutSine);
private readonly DefaultEasingFunction inQuint = new DefaultEasingFunction(Easing.InQuint);

protected override void Update()
Expand All @@ -111,29 +111,29 @@ protected override void Update()
if (Result.HasResult) return;

double fadeIn = AnimationDuration.Value * GameplaySpeed;
double moveTo = 500 * GameplaySpeed;
double moveTo = HitObject.HitWindows.WindowFor(HitResult.Meh) * 2 * GameplaySpeed;
double animStart = HitObject.StartTime - fadeIn - moveTo;
double currentProg = Clock.CurrentTime - animStart;

// Calculate initial entry animation
float fadeAmount = Math.Clamp((float)(currentProg / fadeIn), 0, 1);

Alpha = fadeAmount * (float)inOutBack.ApplyEasing(fadeAmount);
Scale = new Vector2(fadeAmount * (float)inOutBack.ApplyEasing(fadeAmount));
Alpha = fadeAmount * (float)outSine.ApplyEasing(fadeAmount);
Scale = new Vector2(fadeAmount * (float)outSine.ApplyEasing(fadeAmount));

// Calculate position
float moveAmount = Math.Clamp((float)((currentProg - fadeIn) / moveTo), 0, 1);

// Used to simplify this crazy arse manual animating
float moveAnimFormula(float originalValue) => (float)(originalValue - (originalValue * moveAmount * inQuint.ApplyEasing(moveAmount)));
float moveAnimFormula(float originalValue) => (float)(originalValue - (originalValue * inQuint.ApplyEasing(moveAmount)));

blob1.Position = new Vector2(moveAnimFormula(40), 0);
blob2.Position = new Vector2(moveAnimFormula(-40), 0);
blob3.Position = new Vector2(0, moveAnimFormula(40));
blob4.Position = new Vector2(0, moveAnimFormula(-40));

// Used to simplify this crazy arse manual animating
float sizeAnimFormula() => (float)(.5 + .5 * moveAmount * inQuint.ApplyEasing(moveAmount));
float sizeAnimFormula() => (float)(.5 + .5 * inQuint.ApplyEasing(moveAmount));

blob1.Scale = new Vector2(sizeAnimFormula());
blob2.Scale = new Vector2(sizeAnimFormula());
Expand Down Expand Up @@ -187,8 +187,8 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
var result = HitObject.HitWindows.ResultFor(timeOffset);
if (timeOffset < 0 && result <= HitResult.Miss)
return;
if (result >= HitResult.Meh && timeOffset < 0)
result = HitResult.Perfect;
if (result >= HitResult.Meh && result < HitResult.Great && timeOffset < 0)
result = HitResult.Great;

ApplyResult(r => r.Type = result);
}
Expand Down