From ae440a8108ec8ed4b01b6f53fa2aab4d7f0df661 Mon Sep 17 00:00:00 2001 From: sadbeast Date: Mon, 15 Apr 2024 18:08:28 -0700 Subject: initial mistake --- examples/game.zig | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 examples/game.zig (limited to 'examples/game.zig') 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! +} -- cgit v1.2.3