smrendererv3/SMCode/SM2D/Drawing/DrawParticles.cs
2021-03-17 17:09:59 +01:00

32 lines
No EOL
1,019 B
C#

using System;
using OpenTK;
using SM.Base.Drawing.Particles;
using SM.Base.Utility;
using SM2D.Types;
namespace SM2D.Drawing
{
public class DrawParticles : ParticleDrawingBasis<Transformation, Vector2>
{
public override Func<Vector2, ParticleContext, Vector2> MovementCalculation { get; set; } = ParticleMovement.Default2D;
public DrawParticles(TimeSpan duration) : base(duration)
{
}
protected override ParticleStruct<Vector2> CreateObject(int index)
{
return new ParticleStruct<Vector2>()
{
Matrix = Matrix4.CreateScale(1),
Direction = new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1)),
Speed = Randomize.GetFloat(MaxSpeed)
};
}
protected override Matrix4 CreateMatrix(ParticleStruct<Vector2> Struct, Vector2 direction)
{
return Struct.Matrix * Matrix4.CreateTranslation(direction.X, direction.Y, 0);
}
}
}