Preferred method for large, centred maps? #174
-
At the core of it,
In A similar question applies for z-levels where you need to know how many layers you'll want below the default z-layer, since in What's the blessed approach to centered maps like this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi! Ideally for large maps you should chunk. This allows you to use u64 or even u128 for global tile positions. 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>>,
pub chunk_pos: IVec2,
pub transform: Transform,
} Tile: // Use a bundle here and wrap data in Components.
pub struct Tile {
pub texture_id: u16,
pub local_tile_pos: UVec2,
pub global_tile_pos: (i64, i64),
}; With the new API design this is doable. See: I'm planning on creating an infinite map example in the coming future which will showcase some of this off. 👍 |
Beta Was this translation helpful? Give feedback.
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: