mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 12:06:37 +00:00
23 lines
722 B
C#
23 lines
722 B
C#
using Microsoft.Xna.Framework;
|
|
|
|
namespace MonoGame.Extended.Particles.Modifiers
|
|
{
|
|
public class LinearGravityModifier : IModifier
|
|
{
|
|
public Vector2 Direction { get; set; }
|
|
public float Strength { get; set; }
|
|
|
|
public unsafe void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
|
|
{
|
|
var vector = Direction*(Strength*elapsedSeconds);
|
|
|
|
while (iterator.HasNext)
|
|
{
|
|
var particle = iterator.Next();
|
|
particle->Velocity = new Vector2(
|
|
particle->Velocity.X + vector.X*particle->Mass,
|
|
particle->Velocity.Y + vector.Y*particle->Mass);
|
|
}
|
|
}
|
|
}
|
|
} |