Skip to content
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

Added feature to support infinite maps. #552

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

jhonatancarvalho
Copy link

Description

New Feature for Implementing an Infinite Map using the Tiled Library to manage tiles and map components, allowing the map to expand dynamically as the player moves, creating the illusion of an infinite world.

Feature Summary:

1. Dynamic Chunk Management:

  • The class handles the dynamic loading of map "chunks," which are blocks of tiles and components, based on the player's camera position. This allows the map to expand as needed, ensuring that only visible or nearby chunks are loaded.

2. Infinite Map Types:

  • The class supports different types of infinite maps (OPEN, VERTICAL, HORIZONTAL), adjusting the chunk loading based on the selected type.

3. Chunk Loading and Removal:

  • The _loadChunks method is responsible for loading new chunks as the player approaches the edges of the visible map. The _removeDistantChunks method removes chunks that are too far from the player's current position, freeing up resources.

4. Tile and Component Maintenance:

  • The class maintains a map of the initial tiles and loads new tiles and components for each chunk as needed. The methods _buildLayersChunk and _buildComponentsChunk handle this task.

5. Optimization and Performance Management:

  • The class uses data structures like maps (Map) and sets (Set) to track loaded chunks and avoid unnecessary reloading, improving performance.

6. Integration with Bonfire and Tiled:

  • The class integrates directly with Bonfire and Tiled, using the TiledWorldBuilder to construct and manage the map content.

7. Camera Control and Margins:

  • The class considers margins around the camera to decide when to load or remove chunks, ensuring that the transition between chunks is smooth and imperceptible to the player.

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]). This will ensure a smooth and quick review process.

  • I open this PR to the develop branch.
  • I have added a description of the change under [next] in CHANGELOG.md.
  • I ran dart format --output=none --set-exit-if-changed . and has success.

Breaking Change

Does your PR require Flame users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change (please indicate a breaking change in CHANGELOG.md).
  • No, this is not a breaking change.

@jhonatancarvalho jhonatancarvalho changed the base branch from master to develop August 16, 2024 01:51
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