diff --git a/build.zig b/build.zig index 0c397aa..62c8425 100644 --- a/build.zig +++ b/build.zig @@ -5,14 +5,17 @@ fn mapgen(b: *std.build.Step) !void { var alloc = std.heap.page_allocator; const maps = [_][2][]const u8{ - [2][]const u8{"./maps/dungeon.json", "./src/maps/dungeon.zig"}, - [2][]const u8{"./maps/RPGmap.json", "./src/maps/overworld.zig"}, + [2][]const u8{ "./maps/dungeon.json", "./src/maps/dungeon.zig" }, + [2][]const u8{ "./maps/RPGmap.json", "./src/maps/overworld.zig" }, }; for (&maps) |map| { - var deno = std.ChildProcess.init(&.{"deno", "run", "-A", "./src/tools/genmap.js", map[0], map[1]}, alloc); + var deno = std.ChildProcess.init(&.{ "deno", "run", "-A", "./src/tools/genmap.js", map[0], map[1] }, alloc); try deno.spawn(); _ = try deno.wait(); + var zig = std.ChildProcess.init(&.{ "zig", "fmt", map[1] }, alloc); + try zig.spawn(); + _ = try zig.wait(); std.log.info("generated map {s}", .{map[1]}); } @@ -22,7 +25,7 @@ fn release(b: *std.build.Step) !void { _ = b; var alloc = std.heap.page_allocator; - var rel = std.ChildProcess.init(&.{"bash", "./release.sh"}, alloc); + var rel = std.ChildProcess.init(&.{ "bash", "./release.sh" }, alloc); try rel.spawn(); _ = try rel.wait(); @@ -32,7 +35,7 @@ fn release(b: *std.build.Step) !void { pub fn build(b: *std.build.Builder) !void { const map_step = b.step("mapgen", "Generate maps from Tiled JSON"); map_step.makeFn = mapgen; - + const release_step = b.step("release", "Generate release binaries"); release_step.makeFn = release; release_step.dependOn(map_step); diff --git a/src/main.zig b/src/main.zig index 1f26b96..c4b47a8 100644 --- a/src/main.zig +++ b/src/main.zig @@ -120,7 +120,7 @@ fn drawMap() !void { while (row < endRow) { defer row += 1; - var tile = map.data[@intCast(u32, col) * map.width + @intCast(u32, row)]; + var tile = map.get_tile(@intCast(u32, col), @intCast(u32, row)); var x = (row - startCol) * tile_size - offsetX; var y = (col - startRow) * tile_size - offsetY; diff --git a/src/maps/dungeon.zig b/src/maps/dungeon.zig index afb7162..13c6d8b 100644 --- a/src/maps/dungeon.zig +++ b/src/maps/dungeon.zig @@ -10,63 +10,61 @@ const Rect = sh0rk.Rect; pub const width = 20; pub const height = 20; +pub fn get_tile(x: u32, y: u32) u9 { + return data[x * height + y]; +} pub const tileset: Tileset = .Dungeon; pub const ts_width = 14; pub const ts_height = 13; pub const data = [400]u9{ - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 58, 59, 71, 59, 18, 59, 18, - 15, 16, 17, 59, 76, 43, 43, 43, 43, 43, - 43, 43, 43, 72, 79, 32, 73, 32, 73, 32, - 29, 30, 31, 57, 90, 43, 43, 43, 43, 43, - 43, 43, 43, 105, 106, 105, 106, 105, 106, 105, - 106, 105, 106, 105, 106, 43, 43, 43, 43, 43, - 43, 43, 43, 117, 118, 117, 118, 117, 118, 117, - 118, 117, 118, 117, 118, 43, 43, 43, 43, 43, - 43, 43, 43, 131, 132, 103, 104, 103, 104, 103, - 104, 103, 104, 103, 104, 43, 43, 43, 43, 43, - 43, 43, 43, 145, 146, 117, 118, 117, 118, 117, - 118, 117, 118, 117, 118, 43, 43, 43, 43, 43, - 43, 43, 43, 105, 106, 103, 104, 103, 104, 103, - 104, 103, 104, 103, 104, 43, 43, 43, 43, 43, - 43, 43, 43, 117, 118, 117, 118, 117, 118, 117, - 118, 117, 118, 137, 138, 43, 43, 43, 43, 43, - 43, 43, 43, 103, 104, 103, 104, 103, 104, 103, - 104, 103, 104, 151, 152, 43, 43, 43, 43, 43, - 43, 43, 43, 117, 118, 117, 118, 117, 118, 117, - 118, 117, 118, 117, 118, 43, 43, 43, 43, 43, - 43, 43, 43, 93, 94, 121, 94, 121, 94, 121, - 94, 121, 94, 121, 94, 43, 43, 43, 43, 43, - 43, 43, 43, 107, 108, 108, 108, 108, 108, 108, - 108, 108, 108, 108, 108, 43, 43, 43, 43, 43, - 43, 43, 43, 123, 122, 123, 122, 123, 122, 123, - 122, 123, 122, 122, 123, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, - 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 58, 59, 71, 59, 18, 59, + 18, 15, 16, 17, 59, 76, 43, 43, 43, 43, 43, + 43, 43, 43, 72, 79, 32, 73, 32, 73, 32, 29, + 30, 31, 57, 90, 43, 43, 43, 43, 43, 43, 43, + 43, 105, 106, 105, 106, 105, 106, 105, 106, 105, 106, + 105, 106, 43, 43, 43, 43, 43, 43, 43, 43, 117, + 118, 117, 118, 117, 118, 117, 118, 117, 118, 117, 118, + 43, 43, 43, 43, 43, 43, 43, 43, 131, 132, 103, + 104, 103, 104, 103, 104, 103, 104, 103, 104, 43, 43, + 43, 43, 43, 43, 43, 43, 145, 146, 117, 118, 117, + 118, 117, 118, 117, 118, 117, 118, 43, 43, 43, 43, + 43, 43, 43, 43, 105, 106, 103, 104, 103, 104, 103, + 104, 103, 104, 103, 104, 43, 43, 43, 43, 43, 43, + 43, 43, 117, 118, 117, 118, 117, 118, 117, 118, 117, + 118, 137, 138, 43, 43, 43, 43, 43, 43, 43, 43, + 103, 104, 103, 104, 103, 104, 103, 104, 103, 104, 151, + 152, 43, 43, 43, 43, 43, 43, 43, 43, 117, 118, + 117, 118, 117, 118, 117, 118, 117, 118, 117, 118, 43, + 43, 43, 43, 43, 43, 43, 43, 93, 94, 121, 94, + 121, 94, 121, 94, 121, 94, 121, 94, 43, 43, 43, + 43, 43, 43, 43, 43, 107, 108, 108, 108, 108, 108, + 108, 108, 108, 108, 108, 108, 43, 43, 43, 43, 43, + 43, 43, 43, 123, 122, 123, 122, 123, 122, 123, 122, + 123, 122, 122, 123, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, }; pub const coll = [_]Rect{ - Rect{.base = Point{.x = 0, .y = 0}, .width = 159, .height = 54}, - Rect{.base = Point{.x = 0, .y = 55}, .width = 31, .height = 104}, - Rect{.base = Point{.x = 32, .y = 121}, .width = 95, .height = 39}, - Rect{.base = Point{.x = 127, .y = 55}, .width = 32, .height = 105}, - Rect{.base = Point{.x = 112, .y = 98}, .width = 15, .height = 14}, + Rect{ .base = Point{ .x = 0, .y = 0 }, .width = 159, .height = 54 }, + Rect{ .base = Point{ .x = 0, .y = 55 }, .width = 31, .height = 104 }, + Rect{ .base = Point{ .x = 32, .y = 121 }, .width = 95, .height = 39 }, + Rect{ .base = Point{ .x = 127, .y = 55 }, .width = 32, .height = 105 }, + Rect{ .base = Point{ .x = 112, .y = 98 }, .width = 15, .height = 14 }, }; pub const start_point = Point{ .x = 40, .y = 73 }; -pub const triggers = [_]Trigger{ -}; - +pub const triggers = [_]Trigger{}; diff --git a/src/maps/overworld.zig b/src/maps/overworld.zig index 3eab2a6..d04bfcf 100644 --- a/src/maps/overworld.zig +++ b/src/maps/overworld.zig @@ -10,197 +10,185 @@ const Rect = sh0rk.Rect; pub const width = 40; pub const height = 40; +pub fn get_tile(x: u32, y: u32) u9 { + return data[x * height + y]; +} pub const tileset: Tileset = .Rpg; pub const ts_width = 34; pub const ts_height = 16; pub const data = [1600]u9{ - 1, 2, 39, 40, 1, 2, 137, 138, 1, 2, 71, - 72, 73, 74, 75, 76, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 73, 74, 35, 36, 171, 172, 35, 36, 105, - 106, 107, 108, 109, 110, 35, 39, 40, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 139, - 140, 207, 208, 143, 144, 69, 73, 74, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 173, - 174, 241, 242, 177, 178, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 137, - 138, 137, 138, 307, 274, 137, 138, 341, 342, 345, - 346, 411, 412, 137, 138, 1, 2, 33, 34, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 171, - 172, 171, 172, 307, 307, 171, 172, 375, 376, 379, - 380, 445, 446, 171, 172, 35, 36, 67, 68, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 205, - 206, 205, 206, 69, 70, 205, 206, 413, 414, 39, - 40, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 239, - 240, 239, 240, 103, 104, 39, 40, 447, 448, 73, - 74, 307, 104, 239, 274, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 137, 307, 1, 2, 73, 74, 413, 414, 137, - 39, 40, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 171, 172, 35, 36, 171, 172, 447, 448, 171, - 73, 74, 36, 171, 172, 331, 332, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 274, 206, 413, 414, 235, - 236, 233, 234, 205, 364, 365, 366, 367, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 39, 40, 239, 240, 447, 448, 269, - 270, 267, 268, 397, 398, 399, 400, 401, 402, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 237, 238, 73, 74, 137, 138, 413, 414, 233, - 234, 235, 236, 431, 432, 433, 434, 435, 436, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 271, 272, 35, 353, 354, 172, 447, 448, 267, - 268, 269, 270, 465, 466, 467, 468, 469, 470, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 351, 352, 69, 387, 388, 206, 347, 348, 349, - 350, 343, 344, 499, 500, 439, 440, 503, 504, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 385, 386, 103, 104, 239, 240, 381, 121, 121, - 121, 121, 378, 403, 404, 473, 474, 405, 406, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 409, 410, 345, 346, 345, 346, 417, 121, 121, - 121, 121, 418, 345, 346, 417, 418, 345, 346, 345, - 346, 345, 346, 345, 346, 345, 346, 345, 346, 345, - 346, 345, 346, 345, 346, 345, 346, 345, 346, 35, - 36, 443, 444, 379, 380, 379, 380, 451, 452, 451, - 452, 451, 452, 379, 380, 451, 452, 379, 380, 379, - 380, 379, 380, 379, 380, 379, 380, 379, 380, 379, - 380, 379, 380, 379, 380, 379, 380, 379, 380, 69, - 57, 58, 206, 69, 70, 205, 206, 69, 307, 205, - 206, 69, 70, 205, 206, 39, 40, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 90, - 91, 92, 93, 57, 58, 57, 58, 103, 104, 239, - 240, 103, 104, 239, 240, 73, 74, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 91, - 92, 91, 92, 91, 92, 91, 92, 93, 21, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 125, - 126, 125, 126, 125, 126, 125, 126, 127, 94, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 159, - 160, 159, 160, 159, 160, 159, 160, 70, 26, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, - 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, - 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, - 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, - 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, - 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, - 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, - 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, - 240, 103, 104, 239, 240, 103, 104, 239, 240, + 1, 2, 39, 40, 1, 2, 137, 138, 1, 2, 71, + 72, 73, 74, 75, 76, 1, 2, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 1, 2, 137, 138, 35, 36, 73, 74, + 35, 36, 171, 172, 35, 36, 105, 106, 107, 108, 109, + 110, 35, 39, 40, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, + 36, 171, 172, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 139, 140, 207, 208, 143, 144, 69, 73, 74, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 173, 174, + 241, 242, 177, 178, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, + 239, 240, 103, 104, 239, 240, 137, 138, 137, 138, 307, + 274, 137, 138, 341, 342, 345, 346, 411, 412, 137, 138, + 1, 2, 33, 34, 1, 2, 137, 138, 1, 2, 137, + 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, + 137, 138, 171, 172, 171, 172, 307, 307, 171, 172, 375, + 376, 379, 380, 445, 446, 171, 172, 35, 36, 67, 68, + 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, + 172, 35, 36, 171, 172, 35, 36, 171, 172, 205, 206, + 205, 206, 69, 70, 205, 206, 413, 414, 39, 40, 69, + 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, + 206, 69, 70, 205, 206, 239, 240, 239, 240, 103, 104, + 39, 40, 447, 448, 73, 74, 307, 104, 239, 274, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, + 240, 1, 2, 137, 307, 1, 2, 73, 74, 413, 414, + 137, 39, 40, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, + 1, 2, 137, 138, 1, 2, 137, 138, 35, 36, 171, + 172, 35, 36, 171, 172, 447, 448, 171, 73, 74, 36, + 171, 172, 331, 332, 171, 172, 35, 36, 171, 172, 35, + 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, + 35, 36, 171, 172, 69, 70, 205, 206, 69, 70, 274, + 206, 413, 414, 235, 236, 233, 234, 205, 364, 365, 366, + 367, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, + 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 103, 104, 239, 240, 39, 40, 239, 240, 447, 448, 269, + 270, 267, 268, 397, 398, 399, 400, 401, 402, 103, 104, + 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, + 104, 239, 240, 103, 104, 239, 240, 1, 2, 237, 238, + 73, 74, 137, 138, 413, 414, 233, 234, 235, 236, 431, + 432, 433, 434, 435, 436, 1, 2, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 35, 36, 271, 272, 35, 353, 354, 172, + 447, 448, 267, 268, 269, 270, 465, 466, 467, 468, 469, + 470, 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, 69, + 70, 351, 352, 69, 387, 388, 206, 347, 348, 349, 350, + 343, 344, 499, 500, 439, 440, 503, 504, 69, 70, 205, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 69, 70, 205, 206, 103, 104, 385, 386, 103, + 104, 239, 240, 381, 121, 121, 121, 121, 378, 403, 404, + 473, 474, 405, 406, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, + 239, 240, 1, 2, 409, 410, 345, 346, 345, 346, 417, + 121, 121, 121, 121, 418, 345, 346, 417, 418, 345, 346, + 345, 346, 345, 346, 345, 346, 345, 346, 345, 346, 345, + 346, 345, 346, 345, 346, 345, 346, 345, 346, 35, 36, + 443, 444, 379, 380, 379, 380, 451, 452, 451, 452, 451, + 452, 379, 380, 451, 452, 379, 380, 379, 380, 379, 380, + 379, 380, 379, 380, 379, 380, 379, 380, 379, 380, 379, + 380, 379, 380, 379, 380, 69, 57, 58, 206, 69, 70, + 205, 206, 69, 307, 205, 206, 69, 70, 205, 206, 39, + 40, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, + 206, 90, 91, 92, 93, 57, 58, 57, 58, 103, 104, + 239, 240, 103, 104, 239, 240, 73, 74, 239, 240, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 91, 92, 91, + 92, 91, 92, 91, 92, 93, 21, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, + 1, 2, 137, 138, 125, 126, 125, 126, 125, 126, 125, + 126, 127, 94, 171, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, + 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, + 159, 160, 159, 160, 159, 160, 159, 160, 70, 26, 205, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, + 70, 205, 206, 69, 70, 205, 206, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, + 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, + 104, 239, 240, 1, 2, 137, 138, 1, 2, 137, 138, + 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, + 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 35, + 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, + 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, + 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 69, 70, 205, 206, 69, + 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 103, 104, 239, 240, 103, 104, 239, 240, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, + 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, + 138, 1, 2, 137, 138, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, + 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, + 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, + 172, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, + 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, + 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 1, 2, 137, 138, 1, 2, 137, + 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, + 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, + 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, + 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, + 36, 171, 172, 35, 36, 171, 172, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, + 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, 69, + 70, 205, 206, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, + 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, 1, + 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, 138, + 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, 137, + 138, 1, 2, 137, 138, 1, 2, 137, 138, 1, 2, + 137, 138, 1, 2, 137, 138, 35, 36, 171, 172, 35, + 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, 172, + 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, 171, + 172, 35, 36, 171, 172, 35, 36, 171, 172, 35, 36, + 171, 172, 69, 70, 205, 206, 69, 70, 205, 206, 69, + 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, 206, + 69, 70, 205, 206, 69, 70, 205, 206, 69, 70, 205, + 206, 69, 70, 205, 206, 69, 70, 205, 206, 103, 104, + 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, 103, + 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, 240, + 103, 104, 239, 240, 103, 104, 239, 240, 103, 104, 239, + 240, 103, 104, 239, 240, }; pub const coll = [_]Rect{ - Rect{.base = Point{.x = 80, .y = 0}, .width = 47, .height = 16}, - Rect{.base = Point{.x = 128, .y = 70}, .width = 16, .height = 9}, - Rect{.base = Point{.x = 146, .y = 32}, .width = 11, .height = 16}, - Rect{.base = Point{.x = 18, .y = 98}, .width = 12, .height = 13}, - Rect{.base = Point{.x = 114, .y = 16}, .width = 12, .height = 13}, - Rect{.base = Point{.x = 81, .y = 16}, .width = 13, .height = 15}, - Rect{.base = Point{.x = 83, .y = 85}, .width = 26, .height = 27}, - Rect{.base = Point{.x = 100, .y = 81}, .width = 8, .height = 5}, - Rect{.base = Point{.x = 112, .y = 94}, .width = 48, .height = 17}, - Rect{.base = Point{.x = 121, .y = 87}, .width = 30, .height = 7}, - Rect{.base = Point{.x = 128, .y = 80}, .width = 16, .height = 7}, - Rect{.base = Point{.x = 114, .y = 112}, .width = 11, .height = 13}, - Rect{.base = Point{.x = 145, .y = 111}, .width = 12, .height = 13}, - Rect{.base = Point{.x = 11, .y = 146}, .width = 9, .height = 7}, - Rect{.base = Point{.x = 0, .y = 154}, .width = 61, .height = 27}, - Rect{.base = Point{.x = 62, .y = 162}, .width = 8, .height = 11}, + Rect{ .base = Point{ .x = 80, .y = 0 }, .width = 47, .height = 16 }, + Rect{ .base = Point{ .x = 128, .y = 70 }, .width = 16, .height = 9 }, + Rect{ .base = Point{ .x = 146, .y = 32 }, .width = 11, .height = 16 }, + Rect{ .base = Point{ .x = 18, .y = 98 }, .width = 12, .height = 13 }, + Rect{ .base = Point{ .x = 114, .y = 16 }, .width = 12, .height = 13 }, + Rect{ .base = Point{ .x = 81, .y = 16 }, .width = 13, .height = 15 }, + Rect{ .base = Point{ .x = 83, .y = 85 }, .width = 26, .height = 27 }, + Rect{ .base = Point{ .x = 100, .y = 81 }, .width = 8, .height = 5 }, + Rect{ .base = Point{ .x = 112, .y = 94 }, .width = 48, .height = 17 }, + Rect{ .base = Point{ .x = 121, .y = 87 }, .width = 30, .height = 7 }, + Rect{ .base = Point{ .x = 128, .y = 80 }, .width = 16, .height = 7 }, + Rect{ .base = Point{ .x = 114, .y = 112 }, .width = 11, .height = 13 }, + Rect{ .base = Point{ .x = 145, .y = 111 }, .width = 12, .height = 13 }, + Rect{ .base = Point{ .x = 11, .y = 146 }, .width = 9, .height = 7 }, + Rect{ .base = Point{ .x = 0, .y = 154 }, .width = 61, .height = 27 }, + Rect{ .base = Point{ .x = 62, .y = 162 }, .width = 8, .height = 11 }, }; pub const triggers = [_]Trigger{ - Trigger{.aura = Rect{.base = Point{.x = 16, .y = 96}, .width = 16, .height = 20}, .direction = Direction.Up, .dialogue = "18 chars per line\nallowed. Or else!"}, // sign - Trigger{.aura = Rect{.base = Point{.x = 83, .y = 103}, .width = 7, .height = 16}, .direction = Direction.Up, .dialogue = "Ded."}, // gravestone 1 - Trigger{.aura = Rect{.base = Point{.x = 96, .y = 103}, .width = 7, .height = 16}, .direction = Direction.Up, .dialogue = "Moar ded."}, // gravestone 2 + Trigger{ .aura = Rect{ .base = Point{ .x = 16, .y = 96 }, .width = 16, .height = 20 }, .direction = Direction.Up, .dialogue = "18 chars per line\nallowed. Or else!" }, // sign + Trigger{ .aura = Rect{ .base = Point{ .x = 83, .y = 103 }, .width = 7, .height = 16 }, .direction = Direction.Up, .dialogue = "Ded." }, // gravestone 1 + Trigger{ .aura = Rect{ .base = Point{ .x = 96, .y = 103 }, .width = 7, .height = 16 }, .direction = Direction.Up, .dialogue = "Moar ded." }, // gravestone 2 }; pub const start_point = Point{ .x = 32, .y = 31 }; - diff --git a/src/tools/genmap.js b/src/tools/genmap.js index 59c582b..bb1ce10 100644 --- a/src/tools/genmap.js +++ b/src/tools/genmap.js @@ -24,6 +24,11 @@ out += `const Rect = sh0rk.Rect;\n\n`; out += `pub const width = ${map.width};\n`; out += `pub const height = ${map.height};\n\n`; +out += `pub fn get_tile(x: u32, y: u32) u9 { + return data[x * height + y]; +} +`; + let tiles = map.layers[0]; let tilesheet = {