From c8eae871002b57f45b29a2d158e384433e76a90c Mon Sep 17 00:00:00 2001 From: salmonik Date: Fri, 10 Jul 2026 21:16:59 +0200 Subject: Phase 2 --- src/texture.rs | 49 ++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) (limited to 'src/texture.rs') diff --git a/src/texture.rs b/src/texture.rs index bdbb15c..e5720c0 100644 --- a/src/texture.rs +++ b/src/texture.rs @@ -60,6 +60,49 @@ pub fn generate_wall_texture(rng: &mut impl Rng) -> Vec { tex } +/// Gray stone-tile floor with a dark hole in the centre — the exit staircase. +pub fn generate_exit_texture(rng: &mut impl Rng) -> Vec { + let mut tex = generate_floor_texture(rng); + + let cx = TEX_SIZE as f64 / 2.0; + let cy = TEX_SIZE as f64 / 2.0; + let hole_radius = TEX_SIZE as f64 * 0.35; + let fade_zone = TEX_SIZE as f64 * 0.08; + + for y in 0..TEX_SIZE { + for x in 0..TEX_SIZE { + let dx = x as f64 - cx; + let dy = y as f64 - cy; + let dist = (dx * dx + dy * dy).sqrt(); + + if dist < hole_radius { + // Deep black void. + let edge = (dist / hole_radius).clamp(0.0, 1.0); + // Slight blueish tint near the edge for depth. + let r = (8.0 * (1.0 - edge)) as u8; + let g = (6.0 * (1.0 - edge)) as u8; + let b = (12.0 * edge + 4.0 * (1.0 - edge)) as u8; + tex[y * TEX_SIZE + x] = + 0xFF00_0000 | ((r as u32) << 16) | ((g as u32) << 8) | (b as u32); + } else if dist < hole_radius + fade_zone { + // Fade zone: blend from floor to darkness. + let t = ((dist - hole_radius) / fade_zone).clamp(0.0, 1.0); + let floor_color = tex[y * TEX_SIZE + x]; + let fr = ((floor_color >> 16) & 0xFF) as f64; + let fg = ((floor_color >> 8) & 0xFF) as f64; + let fb = (floor_color & 0xFF) as f64; + + let r = (fr * t + 8.0 * (1.0 - t)) as u8; + let g = (fg * t + 6.0 * (1.0 - t)) as u8; + let b = (fb * t + 12.0 * (1.0 - t)) as u8; + tex[y * TEX_SIZE + x] = + 0xFF00_0000 | ((r as u32) << 16) | ((g as u32) << 8) | (b as u32); + } + } + } + tex +} + /// Gray stone-tile floor — 64×64, checkerboard with grout and subtle colour tint. pub fn generate_floor_texture(rng: &mut impl Rng) -> Vec { let seed = rng.gen::(); @@ -68,7 +111,11 @@ pub fn generate_floor_texture(rng: &mut impl Rng) -> Vec { for y in 0..TEX_SIZE { for x in 0..TEX_SIZE { let h = hash(x as u32, y as u32, seed); - let h2 = hash(x.wrapping_add(2000) as u32, y.wrapping_add(2000) as u32, seed); + let h2 = hash( + x.wrapping_add(2000) as u32, + y.wrapping_add(2000) as u32, + seed, + ); let tile_x = x / 16; let tile_y = y / 16; -- cgit v1.2.3