diff options
author | sadbeast <sadbeast@sadbeast.com> | 2024-04-15 18:08:28 -0700 |
---|---|---|
committer | sadbeast <sadbeast@sadbeast.com> | 2024-04-29 03:24:18 +0000 |
commit | ae440a8108ec8ed4b01b6f53fa2aab4d7f0df661 (patch) | |
tree | d0204bdf27618c77c7fb4372d3f453df0a0ae57b /examples/game.zig | |
download | tmz-ae440a8108ec8ed4b01b6f53fa2aab4d7f0df661.tar.gz tmz-ae440a8108ec8ed4b01b6f53fa2aab4d7f0df661.tar.bz2 |
initial mistake
Diffstat (limited to 'examples/game.zig')
-rw-r--r-- | examples/game.zig | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/game.zig b/examples/game.zig new file mode 100644 index 0000000..e86eede --- /dev/null +++ b/examples/game.zig @@ -0,0 +1,24 @@ +const std = @import("std"); +const tmz = @import("tmz"); + +pub fn main() !void { + var buffer: [10_000]u8 = undefined; + const file = try std.fs.cwd().readFile("examples/map.tmj", &buffer); + + var gpa = std.heap.GeneralPurposeAllocator(.{}){}; + const allocator = gpa.allocator(); + defer _ = gpa.deinit(); + + var arena = std.heap.ArenaAllocator.init(allocator); + defer arena.deinit(); + + const map = try tmz.parse(file, arena.allocator()); + + const stdout_file = std.io.getStdOut().writer(); + var bw = std.io.bufferedWriter(stdout_file); + const stdout = bw.writer(); + + try stdout.print("Map: {any}\n", .{map}); + + try bw.flush(); // don't forget to flush! +} |