1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 00:27:26 +08:00
osu-lazer/osu.Game.Mode.Osu/Objects/Drawables/Pieces/Triangles.cs

41 lines
1.3 KiB
C#
Raw Normal View History

using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.Textures;
using osu.Framework.MathUtils;
using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{
2016-12-02 02:12:35 +08:00
public class Triangles : Container<Triangle>
{
protected override void LoadComplete()
{
base.LoadComplete();
2016-12-02 02:12:35 +08:00
const float size = 100;
for (int i = 0; i < 10; i++)
{
2016-12-02 02:12:35 +08:00
Add(new Triangle
{
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
2016-12-02 02:12:35 +08:00
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
Size = new Vector2(size, 0.866f * size),
Alpha = RNG.NextSingle() * 0.3f,
});
}
}
protected override void Update()
{
base.Update();
foreach (Drawable d in Children)
d.Position -= new Vector2(0, (float)(d.Scale.X * (Time.Elapsed / 2880)));
}
}
}