zshift zshift

Niner since 2012


  • Drawing with Emitters

    pColor on line 47 is not used at all. Also, I wrote lines 33-35 like this: 

    var nextParticle = particles[particleIndex++];
    particleIndex %= particles.length;
    nextParticle.reset(targetx, targety);

    %= will constrain the particleIndex to the size of the array, so once particleIndex is 100, the 100 % 100 = 0, 101 % 100 = 1, etc. I post-increment particleIndex as soon as it's used, as this is a little clearer for me here than inside an if, and it makes the line that follows simpler. The only downside that I can see to this is that it's writing to particleIndex twice at every call, whereas your implementation will only write twice every 100 calls. Considering that this is fired based on user input, though, I'd say that this becomes insignificant.Overall this was a good video, and I really enjoyed playing with the numbers and seeing the changes occur.