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

Allow user to provide a vector of image handles, each to be used as a tile texture. #299

Merged
merged 5 commits into from
Oct 3, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/accessing_tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
size: tilemap_size,
storage: tile_storage,
map_type: tilemap_type,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/animation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ fn create_background(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
tile_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
transform: get_tilemap_center_transform(&size, &grid_size, 0.0),
..Default::default()
});
Expand Down Expand Up @@ -114,7 +114,7 @@ fn create_animated_flowers(mut commands: Commands, asset_server: Res<AssetServer
grid_size,
size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&size, &grid_size, 1.0),
..Default::default()
Expand Down
12 changes: 6 additions & 6 deletions examples/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ fn startup(
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand All @@ -77,13 +77,13 @@ fn swap_texture_or_hide(
mut query: Query<(&mut TilemapTexture, &mut Visibility)>,
) {
if keyboard_input.just_pressed(KeyCode::Space) {
let texture_handle_a: Handle<Image> = asset_server.load("tiles.png");
let texture_handle_b: Handle<Image> = asset_server.load("tiles2.png");
let texture_a = TilemapTexture::Single(asset_server.load("tiles.png"));
let texture_b = TilemapTexture::Single(asset_server.load("tiles2.png"));
for (mut tilemap_tex, _) in &mut query {
if tilemap_tex.0 == texture_handle_a {
tilemap_tex.0 = texture_handle_b.clone();
if *tilemap_tex == texture_a {
*tilemap_tex = texture_b.clone();
} else {
tilemap_tex.0 = texture_handle_a.clone();
*tilemap_tex = texture_a.clone();
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion examples/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/chunking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn spawn_chunk(commands: &mut Commands, asset_server: &AssetServer, chunk_pos: I
grid_size: TILE_SIZE.into(),
size: CHUNK_SIZE.into(),
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size: TILE_SIZE,
transform,
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/colors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
map_type: TilemapType::Square {
diagonal_neighbors: false,
Expand Down
12 changes: 6 additions & 6 deletions examples/frustum_cull_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ fn spawn_tilemap(mut commands: Commands, tile_handle_square: Res<TileHandleSquar
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(tile_handle_square.clone()),
texture: TilemapTexture::Single(tile_handle_square.clone()),
tile_size,
map_type: TilemapType::Square {
diagonal_neighbors: false,
Expand Down Expand Up @@ -165,7 +165,7 @@ fn swap_map_type(
diagonal_neighbors: false,
coord_system: IsoCoordSystem::Diamond,
};
*map_texture = TilemapTexture((*tile_handle_iso).clone());
*map_texture = TilemapTexture::Single((*tile_handle_iso).clone());
*tile_size = TILE_SIZE_ISO;
*grid_size = GRID_SIZE_ISO;
}
Expand All @@ -177,7 +177,7 @@ fn swap_map_type(
diagonal_neighbors: false,
coord_system: IsoCoordSystem::Staggered,
};
*map_texture = TilemapTexture((*tile_handle_iso).clone());
*map_texture = TilemapTexture::Single((*tile_handle_iso).clone());
*tile_size = TILE_SIZE_ISO;
*grid_size = GRID_SIZE_ISO;
}
Expand All @@ -186,7 +186,7 @@ fn swap_map_type(
..
} => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Row);
*map_texture = TilemapTexture((*tile_handle_hex_row).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_row).clone());
*tile_size = TILE_SIZE_HEX_ROW;
*grid_size = GRID_SIZE_HEX_ROW;
}
Expand All @@ -198,7 +198,7 @@ fn swap_map_type(
}
TilemapType::Hexagon(HexCoordSystem::RowOdd) => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Column);
*map_texture = TilemapTexture((*tile_handle_hex_col).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_col).clone());
*tile_size = TILE_SIZE_HEX_COL;
*grid_size = GRID_SIZE_HEX_COL;
}
Expand All @@ -212,7 +212,7 @@ fn swap_map_type(
*map_type = TilemapType::Square {
diagonal_neighbors: false,
};
*map_texture = TilemapTexture((*tile_handle_square).clone());
*map_texture = TilemapTexture::Single((*tile_handle_square).clone());
*tile_size = TILE_SIZE_SQUARE;
*grid_size = GRID_SIZE_SQUARE;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/game_of_life.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
map_type: TilemapType::Square {
Expand Down
2 changes: 1 addition & 1 deletion examples/helpers/tiled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ pub fn process_loaded_maps(
grid_size,
size: map_size,
storage: tile_storage,
texture: TilemapTexture(
texture: TilemapTexture::Single(
tiled_map
.tilesets
.get(&tileset.first_gid)
Expand Down
2 changes: 1 addition & 1 deletion examples/hexagon_column.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
map_type: TilemapType::Hexagon(HexCoordSystem::Column),
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions examples/hexagon_generation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn spawn_tilemap(mut commands: Commands, tile_handle_hex_row: Res<TileHandleHexR
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(tile_handle_hex_row.clone()),
texture: TilemapTexture::Single(tile_handle_hex_row.clone()),
tile_size,
map_type: TilemapType::Hexagon(hex_coord_system),
..Default::default()
Expand Down Expand Up @@ -170,11 +170,11 @@ fn swap_map_type(
*map_type = TilemapType::Hexagon(new_coord_sys);

if new_coord_sys == HexCoordSystem::Column {
*map_texture = TilemapTexture((*tile_handle_hex_col).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_col).clone());
*tile_size = TILE_SIZE_HEX_COL;
*grid_size = GRID_SIZE_HEX_COL;
} else if new_coord_sys == HexCoordSystem::Row {
*map_texture = TilemapTexture((*tile_handle_hex_row).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_row).clone());
*tile_size = TILE_SIZE_HEX_ROW;
*grid_size = GRID_SIZE_HEX_ROW;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/hexagon_row.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
map_type: TilemapType::Hexagon(HexCoordSystem::Row),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/iso_diamond.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
map_type: TilemapType::isometric_diamond(false),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/iso_staggered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
map_type: TilemapType::isometric_staggered(false),
..Default::default()
Expand Down
4 changes: 2 additions & 2 deletions examples/layers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle.clone()),
texture: TilemapTexture::Single(texture_handle.clone()),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand All @@ -54,7 +54,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size: grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size: TilemapTileSize { x: 16.0, y: 16.0 },
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 1.0)
* Transform::from_xyz(32.0, 32.0, 0.0),
Expand Down
2 changes: 1 addition & 1 deletion examples/ldtk/ldtk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ pub fn process_loaded_tile_maps(
grid_size,
size,
storage,
texture: TilemapTexture(texture),
texture: TilemapTexture::Single(texture),
tile_size,
transform: get_tilemap_center_transform(
&size,
Expand Down
12 changes: 6 additions & 6 deletions examples/mouse_to_tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fn spawn_tilemap(mut commands: Commands, tile_handle_square: Res<TileHandleSquar
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(tile_handle_square.clone()),
texture: TilemapTexture::Single(tile_handle_square.clone()),
tile_size,
map_type: TilemapType::Square {
diagonal_neighbors: false,
Expand Down Expand Up @@ -200,7 +200,7 @@ fn swap_map_type(
diagonal_neighbors: false,
coord_system: IsoCoordSystem::Diamond,
};
*map_texture = TilemapTexture((*tile_handle_iso).clone());
*map_texture = TilemapTexture::Single((*tile_handle_iso).clone());
*tile_size = TILE_SIZE_ISO;
*grid_size = GRID_SIZE_ISO;
}
Expand All @@ -212,7 +212,7 @@ fn swap_map_type(
diagonal_neighbors: false,
coord_system: IsoCoordSystem::Staggered,
};
*map_texture = TilemapTexture((*tile_handle_iso).clone());
*map_texture = TilemapTexture::Single((*tile_handle_iso).clone());
*tile_size = TILE_SIZE_ISO;
*grid_size = GRID_SIZE_ISO;
}
Expand All @@ -221,7 +221,7 @@ fn swap_map_type(
..
} => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Row);
*map_texture = TilemapTexture((*tile_handle_hex_row).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_row).clone());
*tile_size = TILE_SIZE_HEX_ROW;
*grid_size = GRID_SIZE_HEX_ROW;
}
Expand All @@ -233,7 +233,7 @@ fn swap_map_type(
}
TilemapType::Hexagon(HexCoordSystem::RowOdd) => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Column);
*map_texture = TilemapTexture((*tile_handle_hex_col).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_col).clone());
*tile_size = TILE_SIZE_HEX_COL;
*grid_size = GRID_SIZE_HEX_COL;
}
Expand All @@ -247,7 +247,7 @@ fn swap_map_type(
*map_type = TilemapType::Square {
diagonal_neighbors: false,
};
*map_texture = TilemapTexture((*tile_handle_square).clone());
*map_texture = TilemapTexture::Single((*tile_handle_square).clone());
*tile_size = TILE_SIZE_SQUARE;
*grid_size = GRID_SIZE_SQUARE;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/move_tile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
6 changes: 3 additions & 3 deletions examples/neighbors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ fn spawn_tilemap(mut commands: Commands, tile_handle_hex_row: Res<TileHandleHexR
grid_size,
size: total_size,
storage: tile_storage,
texture: TilemapTexture(tile_handle_hex_row.clone()),
texture: TilemapTexture::Single(tile_handle_hex_row.clone()),
tile_size,
map_type: TilemapType::Hexagon(HexCoordSystem::Row),
..Default::default()
Expand Down Expand Up @@ -191,7 +191,7 @@ fn swap_map_type(
}
TilemapType::Hexagon(HexCoordSystem::RowOdd) => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Column);
*map_texture = TilemapTexture((*tile_handle_hex_col).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_col).clone());
*tile_size = TILE_SIZE_HEX_COL;
*grid_size = GRID_SIZE_HEX_COL;
}
Expand All @@ -203,7 +203,7 @@ fn swap_map_type(
}
TilemapType::Hexagon(HexCoordSystem::ColumnOdd) => {
*map_type = TilemapType::Hexagon(HexCoordSystem::Row);
*map_texture = TilemapTexture((*tile_handle_hex_row).clone());
*map_texture = TilemapTexture::Single((*tile_handle_hex_row).clone());
*tile_size = TILE_SIZE_HEX_ROW;
*grid_size = GRID_SIZE_HEX_ROW;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/random_map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/remove_tiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
2 changes: 1 addition & 1 deletion examples/visibility.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fn startup(mut commands: Commands, asset_server: Res<AssetServer>) {
grid_size,
size: tilemap_size,
storage: tile_storage,
texture: TilemapTexture(texture_handle),
texture: TilemapTexture::Single(texture_handle),
tile_size,
transform: get_tilemap_center_transform(&tilemap_size, &grid_size, 0.0),
..Default::default()
Expand Down
Loading