summaryrefslogtreecommitdiff
path: root/test/counter_v2.zig
blob: 77714705e85eadcf5e4919272d46b16dca973e5a (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
//! Reload fixture, second build: a new field, one gone, the rest moved.
const sk = @import("sketch");

pub const name = "counter";
pub const width = 320;
pub const height = 200;

pub const State = struct {
    streak: u16 = 7,
    label: enum(u8) { cold, warm, hot } = .cold,
    clicks: u32 = 0,
};

pub fn update(state: *State, in: *const sk.Input) void {
    for (in.events) |e| if (e.kind == .mouse_up) {
        state.clicks += 10;
    };
}

pub fn draw(state: *const State, f: *sk.Frame) void {
    f.clear(0x302820);
    f.print(8, 8, 2, 0xffffff, "clicks {d} streak {d}", .{ state.clicks, state.streak });
}