summaryrefslogtreecommitdiff
path: root/test/counter_v1.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-25 21:47:58 -0300
committerGabriel Schneider <[email protected]>2026-09-25 21:48:16 -0300
commit9c33714591a2147f7e5879e77212ca9886d0c967 (patch)
treed250be9d9bc365d7894d49455c0f6376966b58be /test/counter_v1.zig
downloadsketchbook-9c33714591a2147f7e5879e77212ca9886d0c967.tar.gz
sketchbook-9c33714591a2147f7e5879e77212ca9886d0c967.zip
Put the game first: lib/sketchbook, sketches/vecanim
The root is the game. The platform library moves to lib/sketchbook (with serve_web.py, which serves any sketch's web build, as a tool of it), and vecanim to sketches/vecanim, still its own package on the same library.
Diffstat (limited to 'test/counter_v1.zig')
-rw-r--r--test/counter_v1.zig24
1 files changed, 24 insertions, 0 deletions
diff --git a/test/counter_v1.zig b/test/counter_v1.zig
new file mode 100644
index 0000000..28f7379
--- /dev/null
+++ b/test/counter_v1.zig
@@ -0,0 +1,24 @@
+//! Reload fixture, first build: counts clicks.
+const sk = @import("sketch");
+
+pub const name = "counter";
+pub const width = 320;
+pub const height = 200;
+
+pub const State = struct {
+ clicks: u32 = 0,
+ label: enum(u8) { cold, warm } = .cold,
+ retired: f32 = 1,
+};
+
+pub fn update(state: *State, in: *const sk.Input) void {
+ for (in.events) |e| if (e.kind == .mouse_up) {
+ state.clicks += 1;
+ if (state.clicks >= 2) state.label = .warm;
+ };
+}
+
+pub fn draw(state: *const State, f: *sk.Frame) void {
+ f.clear(0x202830);
+ f.print(8, 8, 2, 0xffffff, "clicks {d}", .{state.clicks});
+}