HTML and CSS Reference
In-Depth Information
Explosions and particles
When a rock, saucer, or the player ship is destroyed, that object explodes into a series of
particles. The createExplode() function creates this so-called particle explosion. Particles
are simply individual logical display objects with their own life , dx , and dy values. Ran-
domly generating these values makes each explosion appear to be unique. Particles will be
stored in the particles array.
Like missiles, particle objects are rather simple. They also contain enough information to
move them across the screen and to calculate their life span in frame ticks:
newParticle . dx = Math . random () * 3 ;
newParticle . dy = Math . random () * 3 ;
newParticle . life = Math . floor ( Math . random () * 30 + 30 );
newParticle . lifeCtr = 0 ;
newParticle . x = x ;
newParticle . y = y ;
Search WWH ::




Custom Search