diff options
| author | Gabriel Schneider <[email protected]> | 2026-09-25 21:47:58 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-09-25 21:48:16 -0300 |
| commit | 9c33714591a2147f7e5879e77212ca9886d0c967 (patch) | |
| tree | d250be9d9bc365d7894d49455c0f6376966b58be /test/readme.zig | |
| download | sketchbook-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/readme.zig')
| -rw-r--r-- | test/readme.zig | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/test/readme.zig b/test/readme.zig new file mode 100644 index 0000000..70673db --- /dev/null +++ b/test/readme.zig @@ -0,0 +1,16 @@ +//! The example from README.md, compiled by `zig build test`. +const sk = @import("sketch"); + +pub const State = struct { x: f32 = 480, y: f32 = 300, hue: f32 = 0 }; + +pub fn update(s: *State, in: *const sk.Input) void { + if (in.pressed(sk.Key.space)) s.hue += 30; + s.x += (in.mouse_x - s.x) * 0.1; + s.y += (in.mouse_y - s.y) * 0.1; +} + +pub fn draw(s: *const State, f: *sk.Frame) void { + f.clear(0x202020); + f.fill(.{ .x = s.x - 10, .y = s.y - 10, .w = 20, .h = 20 }, 0xff8040); + f.print(8, 8, 2, 0xffffff, "hue {d}", .{s.hue}); +} |
