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

+21
View File
@@ -191,6 +191,7 @@ impl Game {
self.impact(&f);
}
self.spawn_lava_particles(dt);
self.spawn_torch_smoke(dt);
// particles
for p in self.parts.iter_mut() {
p.t += dt;
@@ -395,6 +396,25 @@ impl Game {
}
}
// a thin wisp of smoke above every known torch, now and then a spark
fn spawn_torch_smoke(&mut self, dt: f32) {
let spots: Vec<(f32, f32)> = self.torches.iter().filter(|t| self.map.shown(t.wall)).map(|t| t.pos()).collect();
for (x, y) in spots {
if self.parts.len() >= PARTS_MAX - 100 {
break;
}
if self.vrng.f() < 1.1 * dt {
let v = ((self.vrng.f() - 0.5) * 0.08, (self.vrng.f() - 0.5) * 0.08, 0.32 + self.vrng.f() * 0.12);
let life = 1.8 + self.vrng.f() * 0.6;
self.part(SMOKE, (x, y, 1.0), v, life, abgr(70, 62, 58), 0.05);
}
if self.vrng.f() < 0.25 * dt {
let v = ((self.vrng.f() - 0.5) * 0.3, (self.vrng.f() - 0.5) * 0.3, 0.9);
self.part(EMBER, (x, y, 0.95), v, 0.9, abgr(255, 170, 60), 0.025);
}
}
}
fn spawn_lava_particles(&mut self, dt: f32) {
if self.parts.len() >= PARTS_MAX {
return;
@@ -466,6 +486,7 @@ mod tests {
#[test]
fn projectiles_trail_and_explode_and_arrows_stick() {
let mut g = Game::new(3, 64, 64);
g.torches.clear(); // no torch smoke in the count below
let (cx, cy) = g.map.core;
let (x, y) = (cx as f32 + 1.5, cy as f32 - 1.5);
g.shot(x, y, 0.5, x + 3.0, y, 0.45, 0.3, 0xffffffff);