1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 17:47:29 +08:00

Use new framework-level triangles.

This commit is contained in:
Thomas Müller 2016-12-01 19:12:35 +01:00
parent 20947623d5
commit 1e8dc780ab
5 changed files with 16 additions and 27 deletions

@ -1 +1 @@
Subproject commit 976d7833e85ff880e9b00e8c121747f59becb2d8 Subproject commit c7e33572ceb96df9f0345dc63f689f7d433bf7b0

View File

@ -8,29 +8,24 @@ using OpenTK;
namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces namespace osu.Game.Modes.Osu.Objects.Drawables.Pieces
{ {
public class Triangles : Container public class Triangles : Container<Triangle>
{ {
private Texture triangle;
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
triangle = textures.Get(@"Play/osu/triangle@2x");
}
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
const float size = 100;
for (int i = 0; i < 10; i++) for (int i = 0; i < 10; i++)
{ {
Add(new Sprite Add(new Triangle
{ {
Texture = triangle,
Origin = Anchor.Centre, Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()), Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f), Scale = new Vector2(RNG.NextSingle() * 0.4f + 0.2f),
Alpha = RNG.NextSingle() * 0.3f // 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,
}); });
} }
} }

View File

@ -13,10 +13,8 @@ using OpenTK;
namespace osu.Game.Graphics.Backgrounds namespace osu.Game.Graphics.Backgrounds
{ {
public class Triangles : Container public class Triangles : Container<Triangle>
{ {
private Texture triangle;
public Triangles() public Triangles()
{ {
Alpha = 0.3f; Alpha = 0.3f;
@ -35,12 +33,6 @@ namespace osu.Game.Graphics.Backgrounds
} }
} }
[BackgroundDependencyLoader]
private void load(TextureStore textures)
{
triangle = textures.Get(@"Play/osu/triangle@2x");
}
private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800 / triangleScale); private int aimTriangleCount => (int)((DrawWidth * DrawHeight) / 800 / triangleScale);
protected override void Update() protected override void Update()
@ -60,16 +52,18 @@ namespace osu.Game.Graphics.Backgrounds
} }
protected virtual Sprite CreateTriangle() protected virtual Triangle CreateTriangle()
{ {
var scale = triangleScale * RNG.NextSingle() * 0.4f + 0.2f; var scale = triangleScale * RNG.NextSingle() * 0.4f + 0.2f;
const float size = 100;
return new Sprite return new Triangle
{ {
Texture = triangle,
Origin = Anchor.TopCentre, Origin = Anchor.TopCentre,
RelativePositionAxes = Axes.Both, RelativePositionAxes = Axes.Both,
Scale = new Vector2(scale), Scale = new Vector2(scale),
// Scaling height by 0.866 results in equiangular triangles (== 60° and equal side length)
Size = new Vector2(size, 0.866f * size),
Alpha = RNG.NextSingle(), Alpha = RNG.NextSingle(),
Depth = scale, Depth = scale,
}; };

View File

@ -195,7 +195,7 @@ namespace osu.Game.Graphics.Cursor
colour.BottomLeft.Linear.A = Parts[i].Time + colour.BottomLeft.Linear.A; colour.BottomLeft.Linear.A = Parts[i].Time + colour.BottomLeft.Linear.A;
colour.BottomRight.Linear.A = Parts[i].Time + colour.BottomRight.Linear.A; colour.BottomRight.Linear.A = Parts[i].Time + colour.BottomRight.Linear.A;
Texture.Draw( Texture.DrawQuad(
new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y), new Quad(pos.X - Size.X / 2, pos.Y - Size.Y / 2, Size.X, Size.Y),
colour, colour,
null, null,

View File

@ -213,7 +213,7 @@ namespace osu.Game.Screens.Menu
Alpha = 1; Alpha = 1;
} }
protected override Sprite CreateTriangle() protected override Triangle CreateTriangle()
{ {
var triangle = base.CreateTriangle(); var triangle = base.CreateTriangle();
triangle.Alpha = 1; triangle.Alpha = 1;