Skip to content

Game Optimization and Bug Fixes #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

Taiizor
Copy link
Contributor

@Taiizor Taiizor commented Dec 15, 2024

This pull request includes several changes to improve the game's performance and enhance the user experience. The most important changes involve the addition of a segment pool for better memory management, modifications to the game state update logic, and improvements to the rendering of player snakes.

Memory management improvements:

  • public/config.js: Added MAX_POOL_SIZE and POWERUP_DURATION to the configuration.
  • public/game.js: Introduced a segment pool to manage snake segments efficiently, reducing memory allocation overhead. [1] [2] [3]

Game state updates:

  • public/game.js: Updated the state update logic to reset segments to the pool and retrieve them from the pool, ensuring efficient reuse of segment objects.
  • server/src/socket/socketHandler.js: Added allPlayers to the state update to include all alive players' information. [1] [2]

Rendering improvements:

  • public/game.js: Refactored the player rendering logic into a new batchRenderSnakes method for more efficient rendering of player snakes.

Other changes:

  • server/src/config/gameConfig.js: Adjusted BROADCAST_RATE to improve the game's update frequency.
  • public/ui.js: Modified the powerup display logic to only show the powerup text when the remaining duration is less than or equal to the configured duration.

Screenshots

image

@Taiizor Taiizor changed the title Game Optimization Game Optimization and Bug Fixes Dec 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant