Game Development Reference
In-Depth Information
ctx.globalAlpha = 1.0;
ctx.globalCompositeOperation = 'source-over';
}, 1000/30);
window.setInterval(function() {
if(controls.hasFocus) {
emit(system, images, controls.mouse.x, controls.mouse.y);
}
}, 1000/10);
}
loadImages('smoke.0.png smoke.1.png smoke.2.png smoke.3.png smoke.4.png'.split(' '),
main);
The forces acting on the smoke and fire are exactly the same. You can play with the result of this in
smoke.0.html .
Optimizations
Our current particle system performs quite well for a relatively low (~1000) number of particles. If we need
more particles than that, we need to write more optimized code. This will allow us to have tens of
thousands of particles. To demonstrate how to do this, we will re-implement the fireworks demo in a more
optimized fashion (see Figure 6-8).
Figure 6-8. High-performance fireworks in action
 
Search WWH ::




Custom Search