Add the cascade animation as a separate widget

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2026-02-10 17:43:55 +01:00
parent f320d3f666
commit d268d5bb45
15 changed files with 276 additions and 148 deletions

View File

@@ -13,12 +13,22 @@ pub const SPREAD_MAX = 4;
allocator: Allocator,
terminal_buffer: *TerminalBuffer,
timeout: *bool,
buffer: []u8,
height: u8,
spread: u8,
fire: [STEPS + 1]Cell,
pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, top_color: u32, middle_color: u32, bottom_color: u32, fire_height: u8, fire_spread: u8) !Doom {
pub fn init(
allocator: Allocator,
terminal_buffer: *TerminalBuffer,
top_color: u32,
middle_color: u32,
bottom_color: u32,
fire_height: u8,
fire_spread: u8,
timeout: *bool,
) !Doom {
const buffer = try allocator.alloc(u8, terminal_buffer.width * terminal_buffer.height);
initBuffer(buffer, terminal_buffer.width);
@@ -42,6 +52,7 @@ pub fn init(allocator: Allocator, terminal_buffer: *TerminalBuffer, top_color: u
return .{
.allocator = allocator,
.terminal_buffer = terminal_buffer,
.timeout = timeout,
.buffer = buffer,
.height = @min(HEIGHT_MAX, fire_height),
.spread = @min(SPREAD_MAX, fire_spread),
@@ -71,6 +82,8 @@ fn realloc(self: *Doom) !void {
}
fn draw(self: *Doom) void {
if (self.timeout.*) return;
for (0..self.terminal_buffer.width) |x| {
// We start from 1 so that we always have the topmost line when spreading fire
for (1..self.terminal_buffer.height) |y| {