Draknek/FlashPunk — pull request #54 by BlckKnght (2011-12-10 20:25:43+00:00)
Title: Particle gravity

The current code implementing gravity for particles is not good. First of all, it makes the Emitter class's render() method not idempotent (that means, calling it twice in succession will give get different results) and will give different results depending on the frame rate. Its calculation for the actual position of the particles is non-physical (they'll follow cubic roughly parabolic paths, but not what you'd expect given their initial speed and the gravity setting).

My new code is simpler and more correct. It simply takes the acceleration from gravity into account when calculating the position, rather than changing the particle's velocity from frame to frame. Code using the old gravity logic may need to be changes to the magnitude of the gravity it requests, but at least this code will give allow the use of sensible units (pixels/sec/sec).