diff --git a/src/world/tiles/tilemap_chunk.rs b/src/world/tiles/tilemap_chunk.rs index 349da55..3bfffb8 100644 --- a/src/world/tiles/tilemap_chunk.rs +++ b/src/world/tiles/tilemap_chunk.rs @@ -66,6 +66,7 @@ impl TilemapChunkSpawner { } pub const FIXTURE_ROW_OFFSET: u16 = 6; +pub const LAYER_ALPHA: f32 = 50_f32 / 255_f32; fn tile_id_to_tileset_index(tile_id: u32) -> Option { if tile_id == 0 { @@ -86,7 +87,6 @@ fn tile_for_depth(real_index: u16, z_diff: i32) -> TileData { const SKY_R: f32 = 133_f32 / 255_f32; const SKY_G: f32 = 167_f32 / 255_f32; const SKY_B: f32 = 178_f32 / 255_f32; - const LAYER_ALPHA: f32 = 70_f32 / 255_f32; if z_diff <= 0 { return TileData { @@ -107,18 +107,13 @@ fn tile_for_depth(real_index: u16, z_diff: i32) -> TileData { }; } - if t < 0.5 { - TileData { - tileset_index: real_index, - color: Color::srgba(1_f32, 1_f32, 1_f32, 1_f32 - t * 2_f32), - visible: true, - } - } else { - TileData { - tileset_index: 0, - color: Color::srgba(SKY_R, SKY_G, SKY_B, (t - 0.5_f32) * 2_f32), - visible: true, - } + let r = (1_f32 - t) + SKY_R * t; + let g = (1_f32 - t) + SKY_G * t; + let b = (1_f32 - t) + SKY_B * t; + TileData { + tileset_index: real_index, + color: Color::srgb(r, g, b), + visible: true, } } @@ -163,7 +158,15 @@ fn populate_chunk_tiles( let tile_data = if is_visible { tile_for_depth(tileset_idx, z_diff) } else { - tile_for_depth(0, 999) + TileData { + tileset_index: 0, + color: Color::srgb( + 133_f32 / 255_f32, + 167_f32 / 255_f32, + 178_f32 / 255_f32, + ), + visible: true, + } }; tiles.push(Some(tile_data)); } else {