mirror of
https://github.com/AlexMacocian/MonoGame.Extended.git
synced 2026-07-24 03:56:31 +00:00
Move source projects into source directory
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace MonoGame.Extended.Particles.Modifiers
|
||||
{
|
||||
public unsafe class VortexModifier : Modifier
|
||||
{
|
||||
// Note: not the real-life one
|
||||
private const float _gravConst = 100000f;
|
||||
|
||||
public Vector2 Position { get; set; }
|
||||
public float Mass { get; set; }
|
||||
public float MaxSpeed { get; set; }
|
||||
|
||||
public override void Update(float elapsedSeconds, ParticleBuffer.ParticleIterator iterator)
|
||||
{
|
||||
while (iterator.HasNext)
|
||||
{
|
||||
var particle = iterator.Next();
|
||||
var diff = Position + particle->TriggerPos - particle->Position;
|
||||
|
||||
var distance2 = diff.LengthSquared();
|
||||
|
||||
var speedGain = _gravConst*Mass/distance2*elapsedSeconds;
|
||||
// normalize distances and multiply by speedGain
|
||||
diff.Normalize();
|
||||
particle->Velocity += diff*speedGain;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user