diff --git a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
index 36f18f6..24643db 100644
--- a/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
+++ b/SMCode/SM.Base/Drawing/Particles/ParticleDrawingBasis.cs
@@ -18,6 +18,7 @@ namespace SM.Base.Drawing.Particles
where TTransform : GenericTransformation, new()
where TDirection : struct
{
+
///
/// The amount of particles
///
diff --git a/SMCode/SM.Base/Time/Timer.cs b/SMCode/SM.Base/Time/Timer.cs
index 649eea3..f6e3c37 100644
--- a/SMCode/SM.Base/Time/Timer.cs
+++ b/SMCode/SM.Base/Time/Timer.cs
@@ -56,7 +56,7 @@ namespace SM.Base.Time
{
base.Ticking(context);
- ElapsedNormalized = Elapsed / Target;
+ ElapsedNormalized = Math.Min(Elapsed / Target, 1);
if (ElapsedNormalized >= 1) Stopping(context);
}
diff --git a/SMCode/SM2D/Drawing/DrawParticles.cs b/SMCode/SM2D/Drawing/DrawParticles.cs
index 0998e8d..90f469a 100644
--- a/SMCode/SM2D/Drawing/DrawParticles.cs
+++ b/SMCode/SM2D/Drawing/DrawParticles.cs
@@ -19,6 +19,11 @@ namespace SM2D.Drawing
///
public Vector2? Direction;
+ ///
+ /// The radius the direction is randomized
+ ///
+ public float DirectionRadius = 25;
+
///
public DrawParticles(TimeSpan duration) : base(duration)
{
@@ -27,10 +32,20 @@ namespace SM2D.Drawing
///
protected override ParticleStruct CreateObject(int index)
{
+ Vector2 dir;
+ if (Direction.HasValue)
+ {
+ Vector2 direction = Direction.Value;
+
+ dir = (new Vector4(direction.X, direction.Y, 1, 1) *
+ Matrix4.CreateRotationZ(MathHelper.DegreesToRadians(Randomize.GetFloat(-DirectionRadius / 2, DirectionRadius / 2)))).Xy;
+ }
+ else dir = new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1));
+
return new ParticleStruct()
{
Matrix = Matrix4.CreateScale(1),
- Direction = Direction.GetValueOrDefault(new Vector2(Randomize.GetFloat(-1, 1), Randomize.GetFloat(-1, 1))),
+ Direction = dir,
Speed = Randomize.GetFloat(MaxSpeed)
};
}
diff --git a/SM_TEST/Program.cs b/SM_TEST/Program.cs
index 3bd922d..2c0f58a 100644
--- a/SM_TEST/Program.cs
+++ b/SM_TEST/Program.cs
@@ -36,8 +36,13 @@ namespace SM_TEST
window.SetScene(scene = new Scene());
- DrawText text = new DrawText(font, "Hi, HI");
- scene.Objects.Add(text);
+ DrawParticles particles = new DrawParticles(TimeSpan.FromSeconds(5))
+ {
+ Direction = new Vector2(0, 1),
+ DirectionRadius = 10
+ };
+ particles.Trigger();
+ scene.Objects.Add(particles);
window.UpdateFrame += WindowOnUpdateFrame;
window.RenderFrame += Window_RenderFrame;