Skip to content

Preferred method for large, centred maps? #174

Answered by StarArawn
BrettWitty asked this question in Q&A
Discussion options

You must be logged in to vote

Hi!

Ideally for large maps you should chunk. This allows you to use u64 or even u128 for global tile positions. TilePos must be a unsigned integer. This is because of how tiles are stored in an array (Negative numbers cannot exist in an array) You can use a hash map for tile storage but there are performance issues when accessing tiles within a hash map. If you would like centered tile maps I would suggest using a transform to shift the map visually instead of having negative tile coordinates.

A structure that would likely work out great for this might look something like this:

Chunk:

// Use a bundle here and wrap data in Components.
pub struct Chunk {
  pub tile_storage: Vec<Option<Entity>>

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BrettWitty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants