mirror of
https://github.com/fairyglade/ly.git
synced 2025-12-20 19:24:53 +00:00
Fix Doom & Matrix animation + bug in migrator
Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
@@ -3,26 +3,23 @@ const Allocator = std.mem.Allocator;
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const utils = @import("../tui/utils.zig");
|
||||
|
||||
const interop = @import("../interop.zig");
|
||||
const termbox = interop.termbox;
|
||||
|
||||
const Doom = @This();
|
||||
|
||||
pub const STEPS = 13;
|
||||
pub const FIRE = [_]utils.Cell{
|
||||
utils.initCell(' ', 9, 0),
|
||||
utils.initCell(0x2591, 2, 0), // Red
|
||||
utils.initCell(0x2592, 2, 0), // Red
|
||||
utils.initCell(0x2593, 2, 0), // Red
|
||||
utils.initCell(0x2588, 2, 0), // Red
|
||||
utils.initCell(0x2591, 4, 2), // Yellow
|
||||
utils.initCell(0x2592, 4, 2), // Yellow
|
||||
utils.initCell(0x2593, 4, 2), // Yellow
|
||||
utils.initCell(0x2588, 4, 2), // Yellow
|
||||
utils.initCell(0x2591, 8, 4), // White
|
||||
utils.initCell(0x2592, 8, 4), // White
|
||||
utils.initCell(0x2593, 8, 4), // White
|
||||
utils.initCell(0x2588, 8, 4), // White
|
||||
utils.initCell(0x2591, 0x00FF0000, 0), // Red
|
||||
utils.initCell(0x2592, 0x00FF0000, 0), // Red
|
||||
utils.initCell(0x2593, 0x00FF0000, 0), // Red
|
||||
utils.initCell(0x2588, 0x00FF0000, 0), // Red
|
||||
utils.initCell(0x2591, 0x00FFFF00, 2), // Yellow
|
||||
utils.initCell(0x2592, 0x00FFFF00, 2), // Yellow
|
||||
utils.initCell(0x2593, 0x00FFFF00, 2), // Yellow
|
||||
utils.initCell(0x2588, 0x00FFFF00, 2), // Yellow
|
||||
utils.initCell(0x2591, 0x00FFFFFF, 4), // White
|
||||
utils.initCell(0x2592, 0x00FFFFFF, 4), // White
|
||||
utils.initCell(0x2593, 0x00FFFFFF, 4), // White
|
||||
utils.initCell(0x2588, 0x00FFFFFF, 4), // White
|
||||
};
|
||||
|
||||
allocator: Allocator,
|
||||
@@ -68,8 +65,13 @@ pub fn draw(self: Doom) void {
|
||||
if (buffer_dest > 12) buffer_dest = 0;
|
||||
self.buffer[dest] = @intCast(buffer_dest);
|
||||
|
||||
self.terminal_buffer.buffer[dest] = toTermboxCell(FIRE[buffer_dest]);
|
||||
self.terminal_buffer.buffer[source] = toTermboxCell(FIRE[buffer_source]);
|
||||
const dest_y = dest / self.terminal_buffer.width;
|
||||
const dest_x = dest % self.terminal_buffer.width;
|
||||
utils.putCell(dest_x, dest_y, FIRE[buffer_dest]);
|
||||
|
||||
const source_y = source / self.terminal_buffer.width;
|
||||
const source_x = source % self.terminal_buffer.width;
|
||||
utils.putCell(source_x, source_y, FIRE[buffer_source]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -82,11 +84,3 @@ fn initBuffer(buffer: []u8, width: usize) void {
|
||||
@memset(slice_start, 0);
|
||||
@memset(slice_end, STEPS - 1);
|
||||
}
|
||||
|
||||
fn toTermboxCell(cell: utils.Cell) termbox.tb_cell {
|
||||
return .{
|
||||
.ch = cell.ch,
|
||||
.fg = cell.fg,
|
||||
.bg = cell.bg,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ const std = @import("std");
|
||||
const Allocator = std.mem.Allocator;
|
||||
const Random = std.Random;
|
||||
const TerminalBuffer = @import("../tui/TerminalBuffer.zig");
|
||||
const utils = @import("../tui/utils.zig");
|
||||
|
||||
const interop = @import("../interop.zig");
|
||||
const termbox = interop.termbox;
|
||||
@@ -151,12 +152,12 @@ pub fn draw(self: *Matrix) void {
|
||||
var fg = self.fg_ini;
|
||||
|
||||
if (dot.value == -1 or dot.value == ' ') {
|
||||
_ = termbox.tb_set_cell(@intCast(x), @intCast(y - 1), ' ', fg, termbox.TB_DEFAULT);
|
||||
utils.putCell(x, y - 1, .{ .ch = ' ', .fg = fg, .bg = termbox.TB_DEFAULT });
|
||||
continue;
|
||||
}
|
||||
|
||||
if (dot.is_head) fg = @intCast(termbox.TB_WHITE | termbox.TB_BOLD);
|
||||
_ = termbox.tb_set_cell(@intCast(x), @intCast(y - 1), @intCast(dot.value), fg, termbox.TB_DEFAULT);
|
||||
if (dot.is_head) fg = @intCast(0x00FFFFFF | termbox.TB_BOLD); // White and bold
|
||||
utils.putCell(x, y - 1, .{ .ch = @intCast(dot.value), .fg = fg, .bg = termbox.TB_DEFAULT });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user