summaryrefslogtreecommitdiff
path: root/test/counter_v1.zig
blob: 28f73795cd07f6d4c75bd78fe4cfed0b65964a5b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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});
}