Brighter torches with animated flames, smoke and sparks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Richard ZinkandClaude Opus 5.5 committed 2026-11-05 15:42:05 +01:00
1 parent a2f7c609c5
commit aa586ffa89
2 files changed
+45 -5

No files matched your search

+24 -5
View File
@@ -1106,7 +1106,7 @@ impl R3d {
for (k, tr) in g.torches.iter().enumerate() {
let (x, z) = tr.pos();
let fl = 0.85 + 0.1 * (t * 9.0 + k as f32 * 1.7).sin() + 0.05 * (t * 23.0 + k as f32).sin();
push(vec3(x, 0.75, z), 4.5, vec3(1.0, 0.62, 0.28), 0.9 * fl, 0.0);
push(vec3(x, 0.85, z), 5.5, vec3(1.0, 0.62, 0.28), 1.5 * fl, 0.0);
}
let (cx, cy) = g.map.core;
let hp = (g.core_hp / CORE_HP).clamp(0.0, 1.0);
@@ -1297,10 +1297,7 @@ impl R3d {
}
}
for (k, tr) in g.torches.iter().enumerate().filter(|(_, tr)| g.map.shown(tr.wall)) {
let (x, z) = tr.pos();
let fl = 1.0 + 0.15 * (t * 11.0 + k as f32 * 2.3).sin();
draw_sphere(vec3(x, 0.78, z), 0.09 * fl, None, Color::new(1.0, 0.55, 0.15, 0.9));
draw_sphere(vec3(x, 0.8, z), 0.05 * fl, None, Color::new(1.0, 0.95, 0.6, 1.0));
draw_torch_flame(tr.pos(), k as f32, t);
}
draw_shadows(g);
if let Some(f) = g.flag {
@@ -2648,6 +2645,28 @@ fn draw_traps_glow(g: &Game, t: f32) {
}
}
// a torch flame: stacked glowing blocks, hot and white at the bottom, red at the tip, that
// sway and flicker; a soft halo around it (the smoke comes from particles.rs)
fn draw_torch_flame((x, z): (f32, f32), k: f32, t: f32) {
let base = 0.72;
let flick = 0.8 + 0.2 * (t * 13.0 + k * 2.1).sin() + 0.1 * (t * 29.0 + k * 0.7).sin();
draw_sphere(vec3(x, base + 0.1, z), 0.24 * flick, None, Color::new(1.0, 0.55, 0.15, 0.16));
let n = 6;
for i in 0..n {
let f = i as f32 / (n - 1) as f32;
let sway = (t * 7.0 + k * 1.3 + f * 2.5).sin() * 0.035 * f;
let sway2 = (t * 5.3 + k * 2.7 + f * 1.9).cos() * 0.025 * f;
let h = base + f * 0.24 * flick;
let size = (0.11 - f * 0.08) * (1.0 + 0.18 * (t * 17.0 + k * 3.1 + f * 4.0).sin());
let c = if f < 0.4 {
vec3(1.0, 0.95, 0.65).lerp(vec3(1.0, 0.68, 0.2), f / 0.4)
} else {
vec3(1.0, 0.68, 0.2).lerp(vec3(0.95, 0.25, 0.06), (f - 0.4) / 0.6)
};
draw_cube(vec3(x + sway, h, z + sway2), Vec3::splat(size), None, Color::new(c.x, c.y, c.z, 0.95 - f * 0.4));
}
}
// particles that glow (embers, sparks, smoke, flashes, shock waves)
fn draw_scorch_glow(g: &Game) {
use crate::particles::*;