Posted March 12, 2025 by Domopremo
this.sharedGeometries
) for common objects like bullets, health kits, coins, and zombies. This reduces the overhead of creating new geometry instances for every object by allowing multiple instances of the same geometry to reference the same memory location.
initParticlePool()
, where a predefined number of particle objects are created and reused throughout the game. This effectively minimizes the need for constant instantiation and destruction of particle objects, which can be expensive.
this.player.maxZombies
, preventing unnecessary computational load by capping the number of active zombies in the scene.
this.cullDistance
). This ensures that bullets are not rendering indefinitely when they're outside the gameplay area or no longer relevant.
this.cullDistance
based on performance (FPS). If the FPS drops, the cull distance is reduced to lessen the computational load, which helps maintain a smoother gameplay experience.
requestAnimationFrame
, which allows the browser to optimize rendering cycles. This ensures that the game updates and redraws visually only when the browser is ready, minimizing CPU usage and maximizing performance.
translate
CSS property for positioning rather than altering the DOM hierarchy repeatedly. This reduces the performance cost associated with frequent reflows and repaints in the browser.