bevy_tilemap icon indicating copy to clipboard operation
bevy_tilemap copied to clipboard

Add auto tile features

Open joshuajbouw opened this issue 5 years ago • 1 comments

What problem does this solve or what need does it fill? Auto tile is immensely awesome with tile sets where you can have natural looking maps.

Describe the solution would you like? The auto tile feature needs to be set so that the tiles when made know their tile neighbours and pick the correct sprite to create beautiful looking maps.

Describe the alternative(s) you've considered? n/a

Additional context n/a

joshuajbouw avatar Nov 03 '20 17:11 joshuajbouw

I'd like to propose something in addition to this: rather than just autotile, it would be great if the actual TextureAtlas index could be selected based off of a generic function. Used in combination with both the tiles index being passed to this function and also with the generic tile data I proposed, we could implement more complicated custom tiling rules.

A dirt tile is a dirt tile. But if its by itself, show tile index X, if its next to grass, show tile index instead Y. Or if a chest is open show index A, but if its locked show index B. etc.

I suppose this could be instead done by actually checking that TileData struct. Perhaps this is a trait for which we can implement such functions.

enum MyTileType {
    Dirt,
    Grass
}

impl TileData for Dirt {
    type TileType = MyTileType;

    fn get_type(&self) -> TileType {
        TileType::Dirt
    }

    fn get_tile_index(&self, map: &Tilemap, position: Point2) -> usize {
        match map.get_data(position + Point2::new(1, 0)).get_type() {
            TileType::Dirt => 0,
            TileType::Grass => 5,
        }
    }
}

I'm not particularly a fan of that get_type but that's just an example off the top of my head how it could be done...

thorlucas avatar Apr 12 '21 03:04 thorlucas