aboutsummaryrefslogtreecommitdiff
path: root/src/main.zig
blob: f55935d09912496b7b54c2359652e07c06af22ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
const std = @import("std");
const IO = @import("frontend/ncurses.zig").IO;
const Action = @import("actions.zig").Action;

fn run(allocator: std.mem.Allocator) !void {
    var io = try IO.init(allocator);
    defer {
        io.deinit();
    }

    try io.displayMessage("Initialized");

    var action = Action.illegal;
    var tick_count: usize = 0;
    while (action != Action.exit) {
        const str = try std.fmt.allocPrint(allocator, "{}", .{tick_count});
        defer allocator.free(str);
        try io.displayMessage(str);

        action = try io.waitForTick();
        switch (action) {
            Action.tick => {
                tick_count += 1;
            },
            else => {},
        }
    }
}

pub fn main() u8 {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    const allocator = gpa.allocator();
    run(allocator) catch {
        return 1;
    };

    return 0;
}