blob: 6816231dfcc791b3ee1d2a56c88448b9502c7df0 (
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
39
|
const std = @import("std");
const IO = @import("frontend/ncurses.zig").IO;
const Action = @import("actions.zig").Action;
pub fn main() u8 {
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
var io = IO.init(allocator) catch |err| {
std.log.err("{}", .{err});
return 1;
};
defer io.deinit();
io.displayMessage("Initialized");
var action = Action.illegal;
var tick_count: usize = 0;
while (action != Action.exit) {
var str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch {
return 1;
};
io.displayMessage(str);
allocator.free(str);
action = io.waitForTick();
switch (action) {
Action.tick => {
str = std.fmt.allocPrintZ(allocator, "{}", .{tick_count}) catch {
return 1;
};
io.displayMessage(str);
allocator.free(str);
tick_count += 1;
},
else => {},
}
}
return 0;
}
|