public void updateForce(Particlef particle, float duration) { _durationAcc += duration; if (Keyboard.IsKeyDown(Key.D) || Keyboard.IsKeyDown(Key.Right)) { particle.addForce(new Vec3f(1000.0f, 0.0f, 0.0f)); } if (Keyboard.IsKeyDown(Key.A) || Keyboard.IsKeyDown(Key.Left)) { particle.addForce(new Vec3f(-1000.0f, 0.0f, 0.0f)); } if (Keyboard.IsKeyDown(Key.Space)) { if (!_wasForced && _durationAcc > 0.5f) { particle.addForce(new Vec3f(0.0f, -200000.0f, 0.0f)); _wasForced = true; _durationAcc = 0.0f; } } else { _wasForced = false; } }
public void add(Particlef particle, IParticleForceGenerator forceGenerator) { ParticleForceRegistration registration = new ParticleForceRegistration(); registration.particle = particle; registration.forceGenerator = forceGenerator; registrations.Add(registration); }
public void updateForce(Particlef particle, float duration) { if (!particle.hasFiniteMass()) { return; } particle.addForce(gravity * particle.Mass); }
public void remove(Particlef particle, IParticleForceGenerator forceGenerator) { foreach (ParticleForceRegistration i in registrations) { if (i.particle == particle && i.forceGenerator == forceGenerator) { registrations.Remove(i); return; } } }