1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 06:07:25 +08:00
osu-lazer/osu.Game.Modes.Osu/Objects/Drawables/Pieces/Triangles.cs

44 lines
1.5 KiB
C#
Raw Normal View History

2016-12-06 17:56:20 +08:00
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
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)));
}
}
}