diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-06 15:58:05 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-06 17:53:43 -0300 |
| commit | e9f9f65ace7650a02cee6bf2b2eb466522485834 (patch) | |
| tree | caf5b7a2344b8da002f3952e3225e0db38b492fc /addons/snake/snake.zig | |
| parent | 75e4787be773c8cbfd2e60e59d409b9556898365 (diff) | |
| download | pardes-e9f9f65ace7650a02cee6bf2b2eb466522485834.tar.gz pardes-e9f9f65ace7650a02cee6bf2b2eb466522485834.zip | |
kinds #36, the five kinds on ABI 3: fake.c with every function (view painting each view's size, search through found, FakeJob cancel) and PA_PICTURES, snake, life and image over the module's prefix and open(path, bytes), image without a record (a Restore reads its file), and pdf.c ported mechanically (tick into pa_tick with its [P/N] prefix, a table of the views it is told, its strip laid out for the view its last key or click came from, the text layer painted for a window of glyphs and read on the tick while some view shows text, a body read keeping nothing, search through found, the record its fit, tint and place, PA_PICTURES); the goldens moved once, said in the report: the art words from the first frame, fake's view line, a pane ticked when opened or loaded, a view told after a frame re-wrapped its tag
Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNAtZenFv4weoMD3cge
Diffstat (limited to 'addons/snake/snake.zig')
| -rw-r--r-- | addons/snake/snake.zig | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/addons/snake/snake.zig b/addons/snake/snake.zig index badafc54..cdbf74d9 100644 --- a/addons/snake/snake.zig +++ b/addons/snake/snake.zig @@ -76,7 +76,7 @@ pub const Snake = extern struct { s.placeFood(); } - pub fn open(s: *Snake, _: ?[]const u8) void { + pub fn open(s: *Snake, _: ?[]const u8, _: ?[]const u8) void { s.rng = addon.seed() | 1; s.restart(); } @@ -88,14 +88,17 @@ pub const Snake = extern struct { return if (!flags.focused or s.dead) s.next.stop() else s.next.every(now, period); } - pub fn paint(s: *const Snake, w: addon.Window, out: addon.Paint) void { + pub fn prefix(s: *const Snake, w: *std.Io.Writer) !void { + try w.print("Snake {d}{s}", .{ s.score, if (s.dead) " over" else "" }); + } + + pub fn paint(s: *const Snake, w: addon.Window, _: addon.Paint) void { const wall: addon.Style = .{ .fg = .index(8) }; for (0..H + 2) |y| for (0..W + 2) |x| if (x % (W + 1) == 0 or y % (H + 1) == 0) w.put(x, y, "#", wall); w.put(1 + s.food.x, 1 + s.food.y, "*", .{ .fg = .index(1), .attrs = .{ .bold = true } }); for (s.segs[0..s.len], 0..) |p, i| w.put(1 + p.x, 1 + p.y, if (i > 0) "o" else if (s.dead) "x" else "@", .{ .fg = .index(2), .attrs = .{ .bold = i == 0 } }); if (s.dead) w.put(0, H + 2, "game over: any key", .{ .fg = .index(1) }) else if (!w.focused) w.put(0, H + 2, "paused", wall); - out.prefix("Snake {d}{s}", .{ s.score, if (s.dead) " over" else "" }); } pub fn key(s: *Snake, k: addon.Key) bool { |
