1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 13:37:25 +08:00

Adjust triangle movement based on amplitude

This commit is contained in:
Dean Herbert 2017-05-24 13:05:11 +09:00
parent 03c745abc3
commit a9d1e54c27
2 changed files with 16 additions and 2 deletions

View File

@ -44,6 +44,11 @@ namespace osu.Game.Graphics.Backgrounds
/// </summary>
public bool HideAlphaDiscrepancies = true;
/// <summary>
/// The relative velocity of the triangles. Default is 1.
/// </summary>
public float Velocity = 1;
public float TriangleScale
{
get { return triangleScale; }
@ -78,7 +83,7 @@ namespace osu.Game.Graphics.Backgrounds
foreach (var t in Children)
{
t.Alpha = adjustedAlpha;
t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale);
t.Position -= new Vector2(0, (float)(t.Scale.X * (50 / DrawHeight) * (Time.Elapsed / 950)) / triangleScale * Velocity);
if (ExpireOffScreenTriangles && t.DrawPosition.Y + t.DrawSize.Y * t.Scale.Y < 0)
t.Expire();
}

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.Input;
using osu.Framework.MathUtils;
using osu.Game.Beatmaps.ControlPoints;
using osu.Game.Graphics;
using osu.Game.Graphics.Backgrounds;
@ -38,6 +39,8 @@ namespace osu.Game.Screens.Menu
private readonly Container colourAndTriangles;
private Triangles triangles;
public Action Action;
public float SizeForFlow => logo == null ? 0 : logo.DrawSize.X * logo.Scale.X * logoBounceContainer.Scale.X * logoHoverContainer.Scale.X * 0.74f;
@ -149,7 +152,7 @@ namespace osu.Game.Screens.Menu
RelativeSizeAxes = Axes.Both,
Colour = OsuPink,
},
new Triangles
triangles = new Triangles
{
TriangleScale = 4,
ColourLight = OsuColour.FromHex(@"ff7db7"),
@ -260,8 +263,14 @@ namespace osu.Game.Screens.Menu
{
base.Update();
const float velocity_adjust_cutoff = 0.98f;
var maxAmplitude = lastBeatIndex >= 0 ? Beatmap.Value?.Track?.CurrentAmplitudes.Maximum ?? 0 : 0;
logoAmplitudeContainer.ScaleTo(1 - maxAmplitude * 0.04f, 50, EasingTypes.OutQuint);
if (maxAmplitude > velocity_adjust_cutoff)
triangles.Velocity = 1 + Math.Max(0, maxAmplitude - velocity_adjust_cutoff) * 50;
else
triangles.Velocity = (float)Interpolation.Damp(triangles.Velocity, 1, 0.995f, Time.Elapsed);
}
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)