Add basic snaking.

This commit is contained in:
Dean Herbert 2016-11-28 16:52:57 +09:00
parent 2616d05767
commit 622c90daf7

View File

@ -1,4 +1,5 @@
using osu.Framework.Graphics; using System.Collections.Generic;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Game.Modes.Objects.Drawables; using osu.Game.Modes.Objects.Drawables;
using osu.Game.Modes.Osu.Objects.Drawables.Pieces; using osu.Game.Modes.Osu.Objects.Drawables.Pieces;
@ -60,15 +61,14 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
{ {
base.LoadComplete(); base.LoadComplete();
for (int i = 0; i < slider.Curve.Length; i += 10)
path.Positions.Add(slider.Curve.PositionAt(i / slider.Curve.Length));
path.PathWidth = startCircle.DrawWidth / 4; path.PathWidth = startCircle.DrawWidth / 4;
//force application of the state that was set before we loaded. //force application of the state that was set before we loaded.
UpdateState(State); UpdateState(State);
} }
double snakeDrawn = 0;
protected override void Update() protected override void Update()
{ {
base.Update(); base.Update();
@ -83,9 +83,30 @@ namespace osu.Game.Modes.Osu.Objects.Drawables
if (currentRepeat % 2 == 1) if (currentRepeat % 2 == 1)
t = 1 - t; t = 1 - t;
} }
ball.Position = slider.Curve.PositionAt(t);
double snake = MathHelper.Clamp((Time.Current - slider.StartTime + 450) / 200, 0, 1);
if (snake != snakeDrawn)
{
if (snake < snakeDrawn)
{
//if we have gone backwards, just clear the path for now.
snakeDrawn = 0;
path.Positions.Clear();
}
const double segment_size = 10;
while (snakeDrawn < snake)
{
snakeDrawn += segment_size;
path.Positions.Add(slider.Curve.PositionAt(snake));
}
snakeDrawn = snake;
path.Positions.Add(slider.Curve.PositionAt(snake));
}
ball.Position = slider.Curve.PositionAt(t);
} }
protected override void UpdateState(ArmedState state) protected override void UpdateState(ArmedState state)