Performance Update 1.4.2
Zombie Survival: Last Stand » Devlog
1. Bulk Geometry Creation for Shared Resources:
- There is a use of shared geometries (
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.
2. Object Pooling for Particles:
- The code includes the initialization of a particle pool with
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.
3. Limitations on Zombie Spawn and Persistence:
- Zombies are only spawned if the total count is below
this.player.maxZombies
, preventing unnecessary computational load by capping the number of active zombies in the scene. - Each zombie also has a structured spawn system that includes position checks and adaptations to reduce spawning in close proximity to other zombies, improving efficiency in rendering and collision checks.
4. Bullet Management:
- Visibility and Distance Checks for Bullets: Bullets are removed from the scene after a certain time or once they exceed a specified distance from the player (
this.cullDistance
). This ensures that bullets are not rendering indefinitely when they're outside the gameplay area or no longer relevant.
5. Performance Monitoring and Adaptive Rendering:
- The game tracks the frame count and FPS over time with mechanisms that dynamically adjust
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.
6. Enhanced Update Frequency for UI Elements:
- The update logic for health kits, coins, and zombie health bars is tied to distance checks to ensure that only nearby or relevant UI elements are actively updated and rendered. This reduces the frequency of unnecessary calculations and rendering operations for elements outside the player's immediate interaction range.
7. Efficient Use of RequestAnimationFrame:
- The main game loop is run using
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.
8. Minimized DOM Manipulation for UI Elements:
- When interacting with health bars and UI elements, the code uses the
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.
Zombie Survival: Last Stand
Top-down zombie survival bro!
More posts
- Easter Egg's 1.5.21 day ago
- Bug Fix's 1.5.11 day ago
- Update 1.51 day ago
- Bug Fix's 1.4.11 day ago
- Update 1.41 day ago
- Update Beta 1.32 days ago
- Bug Fix's 1.2.22 days ago
- Bug Fix's 1.2.13 days ago
Leave a comment
Log in with itch.io to leave a comment.