Merge pull request #212 from Tom94/better-triangles

Use new framework-level triangles.
This commit is contained in:
Dean Herbert 2016-12-02 16:21:04 +09:00 committed by GitHub
commit bc2391578c
5 changed files with 16 additions and 27 deletions

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

View File

@ -8,29 +8,24 @@ using OpenTK;
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()
{
base.LoadComplete();
const float size = 100;
for (int i = 0; i < 10; i++)
{
Add(new Sprite
Add(new Triangle
{
Texture = triangle,
Origin = Anchor.Centre,
RelativePositionAxes = Axes.Both,
Position = new Vector2(RNG.NextSingle(), RNG.NextSingle()),
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
{
public class Triangles : Container
public class Triangles : Container<Triangle>
{
private Texture triangle;
public Triangles()
{
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);
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;
const float size = 100;
return new Sprite
return new Triangle
{
Texture = triangle,
Origin = Anchor.TopCentre,
RelativePositionAxes = Axes.Both,
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(),
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.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),
colour,
null,

View File

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