diff --git a/build.zig b/build.zig index 8654b61..876bee8 100644 --- a/build.zig +++ b/build.zig @@ -1,11 +1,11 @@ const std = @import("std"); -pub fn mapgen(b: *std.build.Step) !void { +fn mapgen(b: *std.build.Step) !void { _ = b; var alloc = std.heap.page_allocator; const maps = [_][2][]const u8{ - [2][]const u8{"./maps/TestMap.json", "./src/maps/test.zig"}, + [2][]const u8{"./maps/rpgbig.json", "./src/maps/rpgbig.zig"}, [2][]const u8{"./maps/RPGmap.json", "./src/maps/rpg.zig"}, }; @@ -16,9 +16,21 @@ pub fn mapgen(b: *std.build.Step) !void { } } +fn release(b: *std.build.Step) !void { + _ = b; + var alloc = std.heap.page_allocator; + + var rel = std.ChildProcess.init(&.{"bash", "./release.sh"}, alloc); + try rel.spawn(); + _ = try rel.wait(); +} + pub fn build(b: *std.build.Builder) !void { const map_step = b.step("mapgen", "generate maps"); map_step.makeFn = mapgen; + + const release_step = b.step("release", "generate release binaries"); + release_step.makeFn = release; const mode = b.standardReleaseOptions(); const lib = b.addSharedLibrary("cart", "src/main.zig", .unversioned); diff --git a/maps/RPGmap.json b/maps/RPGmap.json index bff3f22..795f450 100644 --- a/maps/RPGmap.json +++ b/maps/RPGmap.json @@ -1,326 +1,328 @@ -{ "compressionlevel":-1, - "editorsettings": - { - "export": - { - "format":"json", - "target":"RPGmap.json" - } - }, - "height":10, - "infinite":false, - "layers":[ - { - "data":[1, 1, 1, 18, 1, 19, 20, 21, 1, 18, 69, 1, 35, 52, 1, 36, 53, 38, 35, 52, 1, 18, 1, 18, 86, 88, 104, 1, 18, 17, 35, 52, 35, 52, 105, 1, 18, 35, 92, 1, 18, 69, 1, 1, 105, 35, 52, 1, 81, 1, 52, 35, 1, 18, 105, 67, 66, 97, 98, 99, 1, 68, 35, 52, 105, 66, 67, 114, 115, 116, 18, 103, 88, 88, 106, 1, 1, 100, 118, 101, 52, 1, 1, 1, 103, 88, 88, 88, 107, 88, 11, 13, 1, 12, 1, 69, 1, 18, 35, 52], - "height":10, - "id":1, - "name":"map", - "opacity":1, - "type":"tilelayer", - "visible":true, - "width":10, - "x":0, - "y":0 - }, - { - "draworder":"topdown", - "id":2, - "name":"coll", - "objects":[ - { - "height":16.4511859920595, - "id":1, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":47.3989616206862, - "x":80.301333604805, - "y":-0.325766059248702 - }, - { - "height":9.44721571821236, - "id":6, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":16.2883029624351, - "x":127.863178255116, - "y":70.3654687977196 - }, - { - "height":15.8181818181818, - "id":16, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":11.4545454545455, - "x":146.181818181818, - "y":32 - }, - { - "height":12.7272727272727, - "id":17, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":11.8181818181818, - "x":18, - "y":97.8181818181818 - }, - { - "height":13.4545454545455, - "id":18, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":12, - "x":113.818181818182, - "y":16.3636363636364 - }, - { - "height":14.5454545454545, - "id":19, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":13.0909090909091, - "x":81.2727272727273, - "y":16.3636363636364 - }, - { - "height":26.7272727272727, - "id":20, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":26, - "x":82.9090909090909, - "y":85.2727272727273 - }, - { - "height":4.54545454545455, - "id":21, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":8.18181818181819, - "x":99.6363636363636, - "y":80.9090909090909 - }, - { - "height":17.2727272727273, - "id":22, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":47.6363636363637, - "x":112, - "y":94.1818181818182 - }, - { - "height":7.27272727272728, - "id":23, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":30.3636363636364, - "x":120.727272727273, - "y":86.9090909090909 - }, - { - "height":7.09090909090909, - "id":24, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":16.3636363636364, - "x":127.636363636364, - "y":80 - }, - { - "height":12.5454545454545, - "id":25, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":11.4545454545455, - "x":114.363636363636, - "y":111.818181818182 - }, - { - "height":12.5454545454545, - "id":26, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":12.1818181818182, - "x":145.090909090909, - "y":111.272727272727 - }, - { - "height":6.54545454545453, - "id":27, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":31.0909090909091, - "x":0.363636363636364, - "y":153.272727272727 - }, - { - "height":7.09090909090909, - "id":28, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":8.90909090909091, - "x":11.2727272727273, - "y":146.181818181818 - }, - { - "height":5.81818181818181, - "id":29, - "name":"", - "rotation":0, - "type":"", - "visible":true, - "width":8, - "x":51.8181818181818, - "y":154 - }], - "opacity":1, - "type":"objectgroup", - "visible":true, - "x":0, - "y":0 - }, - { - "draworder":"topdown", - "id":3, - "name":"act", - "objects":[ - { - "height":20, - "id":30, - "name":"sign", - "properties":[ - { - "name":"dialogue", - "type":"string", - "value":"Test message!" - }, - { - "name":"direction", - "type":"string", - "value":"Up" - }], - "rotation":0, - "type":"", - "visible":true, - "width":16, - "x":16, - "y":96 - }, - { - "height":16, - "id":31, - "name":"gravestone 1", - "properties":[ - { - "name":"dialogue", - "type":"string", - "value":"Ded." - }, - { - "name":"direction", - "type":"string", - "value":"Up" - }], - "rotation":0, - "type":"", - "visible":true, - "width":7, - "x":82.64, - "y":103 - }, - { - "height":16, - "id":32, - "name":"gravestone 2", - "properties":[ - { - "name":"dialogue", - "type":"string", - "value":"Moar ded." - }, - { - "name":"direction", - "type":"string", - "value":"Up" - }], - "rotation":0, - "type":"", - "visible":true, - "width":7, - "x":96.18, - "y":103.36 - }], - "opacity":1, - "type":"objectgroup", - "visible":true, - "x":0, - "y":0 - }, - { - "draworder":"topdown", - "id":4, - "name":"spc", - "objects":[ - { - "height":16, - "id":33, - "name":"mara_start", - "rotation":0, - "type":"", - "visible":true, - "width":16, - "x":32, - "y":128 - }], - "opacity":1, - "type":"objectgroup", - "visible":true, - "x":0, - "y":0 - }], - "nextlayerid":5, - "nextobjectid":34, - "orientation":"orthogonal", - "renderorder":"right-down", - "tiledversion":"1.4.3", - "tileheight":16, - "tilesets":[ - { - "firstgid":1, - "source":"..\/sprites\/kenney_rpg.tsx" - }], - "tilewidth":16, - "type":"map", - "version":1.4, - "width":10 +{ "compressionlevel":-1, + "height":10, + "infinite":false, + "layers":[ + { + "data":[1, 1, 1, 18, 1, 19, 20, 21, 1, 18, + 69, 1, 35, 52, 1, 36, 53, 38, 35, 52, + 1, 18, 1, 18, 86, 88, 104, 1, 18, 17, + 35, 52, 35, 52, 105, 1, 18, 35, 92, 1, + 18, 69, 1, 1, 105, 35, 52, 1, 81, 1, + 52, 35, 1, 18, 105, 67, 66, 97, 98, 99, + 1, 68, 35, 52, 105, 66, 67, 114, 115, 116, + 18, 103, 88, 88, 106, 1, 1, 100, 118, 101, + 52, 1, 1, 1, 103, 88, 88, 88, 107, 88, + 11, 13, 1, 12, 1, 69, 1, 18, 35, 52], + "height":10, + "id":1, + "name":"map", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":10, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":2, + "name":"coll", + "objects":[ + { + "class":"", + "height":16.4512, + "id":1, + "name":"", + "rotation":0, + "visible":true, + "width":47.399, + "x":80.3013, + "y":-0.325766 + }, + { + "class":"", + "height":9.44722, + "id":6, + "name":"", + "rotation":0, + "visible":true, + "width":16.2883, + "x":127.863, + "y":70.3655 + }, + { + "class":"", + "height":15.8182, + "id":16, + "name":"", + "rotation":0, + "visible":true, + "width":11.4545, + "x":146.182, + "y":32 + }, + { + "class":"", + "height":12.7273, + "id":17, + "name":"", + "rotation":0, + "visible":true, + "width":11.8182, + "x":18, + "y":97.8182 + }, + { + "class":"", + "height":13.4545, + "id":18, + "name":"", + "rotation":0, + "visible":true, + "width":12, + "x":113.818, + "y":16.3636 + }, + { + "class":"", + "height":14.5455, + "id":19, + "name":"", + "rotation":0, + "visible":true, + "width":13.0909, + "x":81.2727, + "y":16.3636 + }, + { + "class":"", + "height":26.7273, + "id":20, + "name":"", + "rotation":0, + "visible":true, + "width":26, + "x":82.9091, + "y":85.2727 + }, + { + "class":"", + "height":4.54545, + "id":21, + "name":"", + "rotation":0, + "visible":true, + "width":8.18182, + "x":99.6364, + "y":80.9091 + }, + { + "class":"", + "height":17.2727, + "id":22, + "name":"", + "rotation":0, + "visible":true, + "width":47.6364, + "x":112, + "y":94.1818 + }, + { + "class":"", + "height":7.27273, + "id":23, + "name":"", + "rotation":0, + "visible":true, + "width":30.3636, + "x":120.727, + "y":86.9091 + }, + + { + "class":"", + "height":7.09091, + "id":24, + "name":"", + "rotation":0, + "visible":true, + "width":16.3636, + "x":127.636, + "y":80 + }, + { + "class":"", + "height":12.5455, + "id":25, + "name":"", + "rotation":0, + "visible":true, + "width":11.4545, + "x":114.364, + "y":111.818 + }, + { + "class":"", + "height":12.5455, + "id":26, + "name":"", + "rotation":0, + "visible":true, + "width":12.1818, + "x":145.091, + "y":111.273 + }, + { + "class":"", + "height":6.54545, + "id":27, + "name":"", + "rotation":0, + "visible":true, + "width":31.0909, + "x":0.363636, + "y":153.273 + }, + { + "class":"", + "height":7.09091, + "id":28, + "name":"", + "rotation":0, + "visible":true, + "width":8.90909, + "x":11.2727, + "y":146.182 + }, + { + "class":"", + "height":5.81818, + "id":29, + "name":"", + "rotation":0, + "visible":true, + "width":8, + "x":51.8182, + "y":154 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"act", + "objects":[ + { + "class":"", + "height":20, + "id":30, + "name":"sign", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Test message!" + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":16, + "x":16, + "y":96 + }, + { + "class":"", + "height":16, + "id":31, + "name":"gravestone 1", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Ded." + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":7, + "x":82.64, + "y":103 + }, + { + "class":"", + "height":16, + "id":32, + "name":"gravestone 2", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Moar ded." + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":7, + "x":96.18, + "y":103.36 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":4, + "name":"spc", + "objects":[ + { + "class":"", + "height":16, + "id":33, + "name":"mara_start", + "rotation":0, + "visible":true, + "width":16, + "x":32, + "y":32 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":5, + "nextobjectid":34, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.9.0", + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "source":"..\/sprites\/kenney_rpg.tsx" + }], + "tilewidth":16, + "type":"map", + "version":"1.9", + "width":10 } \ No newline at end of file diff --git a/maps/RPGmap.tmx b/maps/RPGmap.tmx index 2b08cc8..25c8529 100644 --- a/maps/RPGmap.tmx +++ b/maps/RPGmap.tmx @@ -1,62 +1,62 @@ - - - - - - - - -1,1,1,18,1,19,20,21,1,18, -69,1,35,52,1,36,53,38,35,52, -1,18,1,18,86,88,104,1,18,17, -35,52,35,52,105,1,18,35,92,1, -18,69,1,1,105,35,52,1,81,1, -52,35,1,18,105,67,66,97,98,99, -1,68,35,52,105,66,67,114,115,116, -18,103,88,88,106,1,1,100,118,101, -52,1,1,1,103,88,88,88,107,88, -11,13,1,12,1,69,1,18,35,52 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + +1,1,1,18,1,19,20,21,1,18, +69,1,35,52,1,36,53,38,35,52, +1,18,1,18,86,88,104,1,18,17, +35,52,35,52,105,1,18,35,92,1, +18,69,1,1,105,35,52,1,81,1, +52,35,1,18,105,67,66,97,98,99, +1,68,35,52,105,66,67,114,115,116, +18,103,88,88,106,1,1,100,118,101, +52,1,1,1,103,88,88,88,107,88, +11,13,1,12,1,69,1,18,35,52 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/maps/rpgbig.json b/maps/rpgbig.json new file mode 100644 index 0000000..cb1f8d1 --- /dev/null +++ b/maps/rpgbig.json @@ -0,0 +1,658 @@ +{ "compressionlevel":-1, + "height":20, + "infinite":false, + "layers":[ + { + "data":[1, 1, 1, 18, 1, 19, 20, 21, 1, 18, 1, 18, 19, 68, 21, 18, 1, 18, 20, 18, + 69, 1, 35, 52, 1, 36, 53, 38, 35, 52, 35, 52, 19, 20, 21, 52, 35, 23, 81, 23, + 1, 18, 1, 18, 86, 88, 104, 1, 18, 17, 1, 18, 36, 55, 38, 18, 1, 97, 115, 99, + 35, 52, 35, 52, 105, 1, 18, 35, 92, 1, 35, 52, 1, 69, 20, 52, 35, 131, 80, 133, + 18, 69, 1, 1, 105, 35, 52, 1, 81, 84, 1, 18, 1, 18, 1, 18, 1, 108, 110, 95, + 52, 35, 1, 18, 105, 67, 66, 97, 98, 99, 35, 89, 88, 88, 88, 88, 88, 88, 107, 88, + 1, 68, 35, 52, 105, 66, 67, 114, 115, 116, 1, 105, 1, 18, 1, 18, 1, 18, 1, 18, + 18, 103, 88, 88, 106, 1, 1, 100, 118, 101, 35, 105, 35, 52, 35, 52, 35, 52, 35, 52, + 52, 1, 1, 1, 103, 88, 88, 88, 107, 88, 90, 104, 1, 18, 81, 18, 1, 69, 1, 18, + 11, 13, 12, 12, 1, 69, 1, 18, 35, 52, 105, 52, 35, 97, 98, 99, 35, 52, 35, 52, + 29, 29, 29, 29, 30, 18, 1, 18, 1, 18, 105, 18, 1, 114, 115, 116, 1, 18, 1, 18, + 29, 29, 29, 47, 35, 52, 35, 52, 35, 52, 105, 52, 35, 100, 118, 101, 84, 20, 69, 52, + 45, 47, 46, 18, 1, 57, 73, 73, 58, 18, 103, 88, 88, 88, 107, 87, 1, 18, 1, 18, + 35, 52, 35, 52, 35, 56, 23, 69, 56, 52, 35, 52, 35, 52, 35, 105, 35, 52, 35, 52, + 1, 18, 1, 18, 1, 74, 73, 73, 75, 18, 1, 18, 1, 18, 1, 105, 1, 18, 1, 18, + 35, 52, 35, 52, 35, 52, 35, 52, 35, 52, 35, 52, 35, 69, 35, 105, 35, 52, 35, 52, + 1, 18, 1, 69, 1, 18, 1, 18, 86, 88, 87, 18, 1, 18, 1, 105, 1, 69, 1, 18, + 35, 52, 35, 52, 35, 52, 35, 52, 105, 68, 105, 52, 35, 52, 35, 105, 35, 52, 35, 52, + 1, 18, 1, 18, 1, 18, 1, 18, 103, 88, 107, 88, 88, 88, 88, 107, 88, 88, 88, 88, + 35, 69, 35, 52, 35, 52, 35, 52, 35, 52, 35, 69, 35, 52, 35, 52, 35, 52, 35, 52], + "height":20, + "id":1, + "name":"map", + "opacity":1, + "type":"tilelayer", + "visible":true, + "width":20, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":2, + "name":"coll", + "objects":[ + { + "class":"", + "height":16.4512, + "id":1, + "name":"", + "rotation":0, + "visible":true, + "width":47.399, + "x":80.3013, + "y":-0.325766 + }, + { + "class":"", + "height":9.44722, + "id":6, + "name":"", + "rotation":0, + "visible":true, + "width":16.2883, + "x":127.863, + "y":70.3655 + }, + { + "class":"", + "height":15.8182, + "id":16, + "name":"", + "rotation":0, + "visible":true, + "width":11.4545, + "x":146.182, + "y":32 + }, + { + "class":"", + "height":12.7273, + "id":17, + "name":"", + "rotation":0, + "visible":true, + "width":11.8182, + "x":18, + "y":97.8182 + }, + { + "class":"", + "height":13.4545, + "id":18, + "name":"", + "rotation":0, + "visible":true, + "width":12, + "x":113.818, + "y":16.3636 + }, + { + "class":"", + "height":14.5455, + "id":19, + "name":"", + "rotation":0, + "visible":true, + "width":13.0909, + "x":81.2727, + "y":16.3636 + }, + { + "class":"", + "height":26.7273, + "id":20, + "name":"", + "rotation":0, + "visible":true, + "width":26, + "x":82.9091, + "y":85.2727 + }, + { + "class":"", + "height":4.54545, + "id":21, + "name":"", + "rotation":0, + "visible":true, + "width":8.18182, + "x":99.6364, + "y":80.9091 + }, + { + "class":"", + "height":17.2727, + "id":22, + "name":"", + "rotation":0, + "visible":true, + "width":47.6364, + "x":112, + "y":94.1818 + }, + { + "class":"", + "height":7.27273, + "id":23, + "name":"", + "rotation":0, + "visible":true, + "width":30.3636, + "x":120.727, + "y":86.9091 + }, + { + "class":"", + "height":7.09091, + "id":24, + "name":"", + "rotation":0, + "visible":true, + "width":16.3636, + "x":127.636, + "y":80 + }, + { + "class":"", + "height":12.5455, + "id":25, + "name":"", + "rotation":0, + "visible":true, + "width":11.4545, + "x":114.364, + "y":111.818 + }, + { + "class":"", + "height":12.5455, + "id":26, + "name":"", + "rotation":0, + "visible":true, + "width":12.1818, + "x":145.091, + "y":111.273 + }, + { + "class":"", + "height":6.54545, + "id":27, + "name":"", + "rotation":0, + "visible":true, + "width":31.0909, + "x":0.363636, + "y":153.273 + }, + { + "class":"", + "height":7.09091, + "id":28, + "name":"", + "rotation":0, + "visible":true, + "width":8.90909, + "x":11.2727, + "y":146.182 + }, + { + "class":"", + "height":5.81818, + "id":29, + "name":"", + "rotation":0, + "visible":true, + "width":8, + "x":51.8182, + "y":154 + }, + { + "class":"", + "height":26.95908776276, + "id":34, + "name":"", + "rotation":0, + "visible":true, + "width":32.0594557178768, + "x":31.6951437210827, + "y":153.739662647091 + }, + { + "class":"", + "height":14.7546358701592, + "id":35, + "name":"", + "rotation":0, + "visible":true, + "width":6.37545994389595, + "x":64.1189114357536, + "y":160.843746584575 + }, + { + "class":"", + "height":20.21931582207, + "id":36, + "name":"", + "rotation":0, + "visible":true, + "width":31.5129877226857, + "x":0, + "y":160.479434587781 + }, + { + "class":"", + "height":16.7583518525265, + "id":37, + "name":"", + "rotation":0, + "visible":true, + "width":47.1784035848301, + "x":0.546467995191082, + "y":181.791686400233 + }, + + { + "class":"", + "height":9.28995591824838, + "id":38, + "name":"", + "rotation":0, + "visible":true, + "width":6.37545994389595, + "x":48.0891835768152, + "y":180.880906408248 + }, + { + "class":"", + "height":7.46839593427813, + "id":39, + "name":"", + "rotation":0, + "visible":true, + "width":13.47954388138, + "x":9.10779991985136, + "y":199.278662246348 + }, + { + "class":"", + "height":47.1784035848301, + "id":40, + "name":"", + "rotation":0, + "visible":true, + "width":63.0259754453714, + "x":80.6951072898831, + "y":192.356734307261 + }, + { + "class":"", + "height":6.37545994389598, + "id":41, + "name":"", + "rotation":0, + "visible":true, + "width":8.92564392145434, + "x":147.910670698386, + "y":276.148493569893 + }, + { + "class":"", + "height":7.2862399358811, + "id":42, + "name":"", + "rotation":0, + "visible":true, + "width":14.2081678749681, + "x":224.780502021932, + "y":136.434842799373 + }, + { + "class":"", + "height":15.78, + "id":43, + "name":"", + "rotation":0, + "visible":true, + "width":15.4832598637473, + "x":224.051878028343, + "y":144.996174724034 + }, + { + "class":"", + "height":8.01486392946919, + "id":44, + "name":"", + "rotation":0, + "visible":true, + "width":7.10408393748406, + "x":216.765638092462, + "y":151.189478669533 + }, + { + "class":"", + "height":16.0297278589384, + "id":45, + "name":"", + "rotation":0, + "visible":true, + "width":45.5389995992568, + "x":209.479398156581, + "y":159.93296659259 + }, + { + "class":"", + "height":6.19330394549894, + "id":46, + "name":"", + "rotation":0, + "visible":true, + "width":7.65055193267514, + "x":240.263761885679, + "y":152.828882655106 + }, + { + "class":"", + "height":12.7509198877919, + "id":48, + "name":"", + "rotation":0, + "visible":true, + "width":13.297387882983, + "x":209.297242158184, + "y":177.05563044191 + }, + { + "class":"", + "height":12.5687638893949, + "id":49, + "name":"", + "rotation":0, + "visible":true, + "width":12.5687638893949, + "x":241.903165871252, + "y":177.237786440308 + }, + { + "class":"", + "height":8.92564392145434, + "id":51, + "name":"", + "rotation":0, + "visible":true, + "width":11.1115159022187, + "x":194.360450289628, + "y":37.7062916681846 + }, + { + "class":"", + "height":7.83270793107216, + "id":52, + "name":"", + "rotation":0, + "visible":true, + "width":11.1115159022187, + "x":227.148530001093, + "y":38.4349156617727 + }, + { + "class":"", + "height":44.0817516120806, + "id":54, + "name":"", + "rotation":0, + "visible":true, + "width":1, + "x":192.174578308864, + "y":0 + }, + { + "class":"", + "height":43.1709716200955, + "id":55, + "name":"", + "rotation":0, + "visible":true, + "width":1, + "x":238.624357900106, + "y":0 + }, + { + "class":"", + "height":15.5440414507772, + "id":58, + "name":"", + "rotation":0, + "visible":true, + "width":45.3367875647669, + "x":273.316062176166, + "y":47.6683937823834 + }, + { + "class":"", + "height":14.2487046632124, + "id":59, + "name":"", + "rotation":0, + "visible":true, + "width":12.1761658031088, + "x":273.575129533679, + "y":64.5077720207254 + }, + { + "class":"", + "height":14.7668393782384, + "id":60, + "name":"", + "rotation":0, + "visible":true, + "width":12.6943005181348, + "x":306.217616580311, + "y":63.7305699481865 + }, + { + "class":"", + "height":5.44041450777203, + "id":61, + "name":"", + "rotation":0, + "visible":true, + "width":34.7150259067357, + "x":279.015544041451, + "y":41.1917098445596 + }, + { + "class":"", + "height":8.03108808290155, + "id":62, + "name":"", + "rotation":0, + "visible":true, + "width":16.0621761658031, + "x":288.082901554404, + "y":32.3834196891192 + }, + + { + "class":"", + "height":6.47668393782383, + "id":64, + "name":"", + "rotation":0, + "visible":true, + "width":13.9896373056995, + "x":289.378238341969, + "y":25.6476683937824 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":3, + "name":"act", + "objects":[ + { + "class":"", + "height":20, + "id":30, + "name":"sign", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Test message!" + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":16, + "x":16, + "y":96 + }, + { + "class":"", + "height":16, + "id":31, + "name":"gravestone 1", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Ded." + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":7, + "x":82.64, + "y":103 + }, + { + "class":"", + "height":16, + "id":32, + "name":"gravestone 2", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Moar ded." + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":7, + "x":96.18, + "y":103.36 + }, + { + "class":"", + "height":22.7979274611399, + "id":56, + "name":"high sign", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Kahsis' Edge" + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":6.7357512953368, + "x":208.290155440415, + "y":1.03626943005181 + }, + { + "class":"", + "height":25.1295336787565, + "id":65, + "name":"Garden Sign", + "properties":[ + { + "name":"dialogue", + "type":"string", + "value":"Check the\\ndungeons!" + }, + { + "name":"direction", + "type":"string", + "value":"Up" + }], + "rotation":0, + "visible":true, + "width":12.9533678756477, + "x":145.077720207254, + "y":272.279792746114 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }, + { + "draworder":"topdown", + "id":4, + "name":"spc", + "objects":[ + { + "class":"", + "height":16, + "id":33, + "name":"mara_start", + "rotation":0, + "visible":true, + "width":16, + "x":32, + "y":32 + }], + "opacity":1, + "type":"objectgroup", + "visible":true, + "x":0, + "y":0 + }], + "nextlayerid":5, + "nextobjectid":66, + "orientation":"orthogonal", + "renderorder":"right-down", + "tiledversion":"1.9.0", + "tileheight":16, + "tilesets":[ + { + "firstgid":1, + "source":"..\/sprites\/kenney_rpg.tsx" + }], + "tilewidth":16, + "type":"map", + "version":"1.9", + "width":20 +} \ No newline at end of file diff --git a/maps/rpgbig.tmx b/maps/rpgbig.tmx index 4ee1e5f..c0db020 100644 --- a/maps/rpgbig.tmx +++ b/maps/rpgbig.tmx @@ -1,62 +1,109 @@ - - - - - - - - -1,1,1,18,1,19,20,21,1,18,1,18,1,18,1,18,1,18,81,18, -69,1,35,52,1,36,53,38,35,52,35,52,35,52,35,52,35,97,98,99, -1,18,1,18,86,88,104,1,18,17,1,18,1,18,1,18,1,114,115,116, -35,52,35,52,105,1,18,35,92,1,35,52,35,52,35,52,35,131,132,133, -18,69,1,1,105,35,52,1,81,1,1,18,1,18,1,18,1,108,110,109, -52,35,1,18,105,67,66,97,98,99,35,52,35,52,35,52,35,52,35,52, -1,68,35,52,105,66,67,114,115,116,1,18,1,18,1,18,1,18,1,18, -18,103,88,88,106,1,1,100,118,101,35,52,35,52,35,52,35,52,35,52, -52,1,1,1,103,88,88,88,107,88,1,18,1,18,1,18,1,18,1,18, -11,13,1,12,1,69,1,18,35,52,35,52,35,52,35,52,35,52,35,52 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + +1,1,1,18,1,19,20,21,1,18,1,18,19,68,21,18,1,18,20,18, +69,1,35,52,1,36,53,38,35,52,35,52,19,20,21,52,35,23,81,23, +1,18,1,18,86,88,104,1,18,17,1,18,36,55,38,18,1,97,115,99, +35,52,35,52,105,1,18,35,92,1,35,52,1,69,20,52,35,131,80,133, +18,69,1,1,105,35,52,1,81,84,1,18,1,18,1,18,1,108,110,95, +52,35,1,18,105,67,66,97,98,99,35,89,88,88,88,88,88,88,107,88, +1,68,35,52,105,66,67,114,115,116,1,105,1,18,1,18,1,18,1,18, +18,103,88,88,106,1,1,100,118,101,35,105,35,52,35,52,35,52,35,52, +52,1,1,1,103,88,88,88,107,88,90,104,1,18,81,18,1,69,1,18, +11,13,12,12,1,69,1,18,35,52,105,52,35,97,98,99,35,52,35,52, +29,29,29,29,30,18,1,18,1,18,105,18,1,114,115,116,1,18,1,18, +29,29,29,47,35,52,35,52,35,52,105,52,35,100,118,101,84,20,69,52, +45,47,46,18,1,57,73,73,58,18,103,88,88,88,107,87,1,18,1,18, +35,52,35,52,35,56,23,69,56,52,35,52,35,52,35,105,35,52,35,52, +1,18,1,18,1,74,73,73,75,18,1,18,1,18,1,105,1,18,1,18, +35,52,35,52,35,52,35,52,35,52,35,52,35,69,35,105,35,52,35,52, +1,18,1,69,1,18,1,18,86,88,87,18,1,18,1,105,1,69,1,18, +35,52,35,52,35,52,35,52,105,68,105,52,35,52,35,105,35,52,35,52, +1,18,1,18,1,18,1,18,103,88,107,88,88,88,88,107,88,88,88,88, +35,69,35,52,35,52,35,52,35,52,35,69,35,52,35,52,35,52,35,52 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main.zig b/src/main.zig index 6c53e20..cce4fcc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -1,8 +1,8 @@ -const w4 = @import("wasm4.zig"); -const sh0rk = @import("sh0rk.zig"); -const sprites = @import("sprites.zig"); -const palette = @import("palette.zig"); -const tframe = @import("tframe.zig"); +const w4 = @import("./wasm4.zig"); +const sh0rk = @import("./sh0rk.zig"); +const sprites = @import("./sprites.zig"); +const palette = @import("./palette.zig"); +const tframe = @import("./tframe.zig"); const std = @import("std"); const fmt = std.fmt; @@ -17,9 +17,13 @@ var frame_count: u32 = 0; var mara_direction: Direction = Direction.Right; var mara_frame: bool = false; var mara_box: Rect = Rect{.base = map.start_point, .width = 16, .height = 16}; -var mara_speed: i32 = 0; +var mara_speed: u16 = 0; var screen = Rect{.base = Point{.x = 0, .y = 0}, .width = 160, .height = 160}; +const screen_width = 10; +const screen_height = 10; +var camera: [screen_height * screen_width]u8 = [_]u8{0} ** (screen_height * screen_width); + var sound_timer: u8 = 0; var textBuf: [160]u8 = undefined; @@ -27,8 +31,17 @@ var done: bool = true; export fn start() void { palette.mist(); -} + var col: u32 = 0; + while(col < screen_width) { + defer col += 1; + var row: u32 = 0; + while(row < screen_height) { + defer row += 1; + camera[row * screen_width + col] = map.data[row * screen_width + col]; + } + } +} fn bonk() void { if (sound_timer != 0) { @@ -56,9 +69,6 @@ fn bonk() void { sound_timer = 12; } -const screen_width = 10; -const screen_height = 10; - fn drawMap() !void { w4.m.colors.* = .{ ._0 = .p3, @@ -75,7 +85,7 @@ fn drawMap() !void { while (row < screen_height) { defer row += 1; - var tile = map.data[col * map.width + row]; + var tile = camera[col * map.width + row]; var tileX = tile % map.ts_width; var tileY = tile / map.ts_width; @@ -100,9 +110,8 @@ fn drawMap() !void { } fn move_mara(gamepad: w4.GamePad) void { - mara_speed -= 1; - if (mara_speed < 0) { - mara_speed = 0; + if (mara_speed > 0) { + mara_speed -= 1; } if (gamepad.up) { mara_direction = Direction.Up; diff --git a/src/maps/rpg.zig b/src/maps/rpg.zig index da1e5ef..25b324c 100644 --- a/src/maps/rpg.zig +++ b/src/maps/rpg.zig @@ -50,5 +50,5 @@ pub const triggers = [_]Trigger{ 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 = 128 }; +pub const start_point = Point{ .x = 32, .y = 32 }; diff --git a/src/maps/rpgbig.zig b/src/maps/rpgbig.zig new file mode 100644 index 0000000..8a598bd --- /dev/null +++ b/src/maps/rpgbig.zig @@ -0,0 +1,111 @@ +// Generated by ./src/tools/genmap.js ./maps/rpgbig.json, DO NOT EDIT + +const sh0rk = @import("../sh0rk.zig"); +const Direction = sh0rk.Direction; +const Point = sh0rk.Point; +const Trigger = sh0rk.Trigger; +const Rect = sh0rk.Rect; + +pub const width = 20; +pub const height = 20; + +pub const ts_width = 17; +pub const ts_height = 8; + +pub const data = [400]u8{ + 0, 0, 0, 17, 0, 18, 19, 20, 0, 17, 0, + 17, 18, 67, 20, 17, 0, 17, 19, 17, 68, + 0, 34, 51, 0, 35, 52, 37, 34, 51, 34, + 51, 18, 19, 20, 51, 34, 22, 80, 22, 0, + 17, 0, 17, 85, 87, 103, 0, 17, 16, 0, + 17, 35, 54, 37, 17, 0, 96, 114, 98, 34, + 51, 34, 51, 104, 0, 17, 34, 91, 0, 34, + 51, 0, 68, 19, 51, 34, 130, 79, 132, 17, + 68, 0, 0, 104, 34, 51, 0, 80, 83, 0, + 17, 0, 17, 0, 17, 0, 107, 109, 94, 51, + 34, 0, 17, 104, 66, 65, 96, 97, 98, 34, + 88, 87, 87, 87, 87, 87, 87, 106, 87, 0, + 67, 34, 51, 104, 65, 66, 113, 114, 115, 0, + 104, 0, 17, 0, 17, 0, 17, 0, 17, 17, + 102, 87, 87, 105, 0, 0, 99, 117, 100, 34, + 104, 34, 51, 34, 51, 34, 51, 34, 51, 51, + 0, 0, 0, 102, 87, 87, 87, 106, 87, 89, + 103, 0, 17, 80, 17, 0, 68, 0, 17, 10, + 12, 11, 11, 0, 68, 0, 17, 34, 51, 104, + 51, 34, 96, 97, 98, 34, 51, 34, 51, 28, + 28, 28, 28, 29, 17, 0, 17, 0, 17, 104, + 17, 0, 113, 114, 115, 0, 17, 0, 17, 28, + 28, 28, 46, 34, 51, 34, 51, 34, 51, 104, + 51, 34, 99, 117, 100, 83, 19, 68, 51, 44, + 46, 45, 17, 0, 56, 72, 72, 57, 17, 102, + 87, 87, 87, 106, 86, 0, 17, 0, 17, 34, + 51, 34, 51, 34, 55, 22, 68, 55, 51, 34, + 51, 34, 51, 34, 104, 34, 51, 34, 51, 0, + 17, 0, 17, 0, 73, 72, 72, 74, 17, 0, + 17, 0, 17, 0, 104, 0, 17, 0, 17, 34, + 51, 34, 51, 34, 51, 34, 51, 34, 51, 34, + 51, 34, 68, 34, 104, 34, 51, 34, 51, 0, + 17, 0, 68, 0, 17, 0, 17, 85, 87, 86, + 17, 0, 17, 0, 104, 0, 68, 0, 17, 34, + 51, 34, 51, 34, 51, 34, 51, 104, 67, 104, + 51, 34, 51, 34, 104, 34, 51, 34, 51, 0, + 17, 0, 17, 0, 17, 0, 17, 102, 87, 106, + 87, 87, 87, 87, 106, 87, 87, 87, 87, 34, + 68, 34, 51, 34, 51, 34, 51, 34, 51, 34, + 68, 34, 51, 34, 51, 34, 51, 34, 51, +}; + +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 = 0, .y = 153}, .width = 31, .height = 7}, + Rect{.base = Point{.x = 11, .y = 146}, .width = 9, .height = 7}, + Rect{.base = Point{.x = 52, .y = 154}, .width = 8, .height = 6}, + Rect{.base = Point{.x = 32, .y = 154}, .width = 32, .height = 27}, + Rect{.base = Point{.x = 64, .y = 161}, .width = 6, .height = 15}, + Rect{.base = Point{.x = 0, .y = 160}, .width = 32, .height = 20}, + Rect{.base = Point{.x = 1, .y = 182}, .width = 47, .height = 17}, + Rect{.base = Point{.x = 48, .y = 181}, .width = 6, .height = 9}, + Rect{.base = Point{.x = 9, .y = 199}, .width = 13, .height = 7}, + Rect{.base = Point{.x = 81, .y = 192}, .width = 63, .height = 47}, + Rect{.base = Point{.x = 148, .y = 276}, .width = 9, .height = 6}, + Rect{.base = Point{.x = 225, .y = 136}, .width = 14, .height = 7}, + Rect{.base = Point{.x = 224, .y = 145}, .width = 15, .height = 16}, + Rect{.base = Point{.x = 217, .y = 151}, .width = 7, .height = 8}, + Rect{.base = Point{.x = 209, .y = 160}, .width = 46, .height = 16}, + Rect{.base = Point{.x = 240, .y = 153}, .width = 8, .height = 6}, + Rect{.base = Point{.x = 209, .y = 177}, .width = 13, .height = 13}, + Rect{.base = Point{.x = 242, .y = 177}, .width = 13, .height = 13}, + Rect{.base = Point{.x = 194, .y = 38}, .width = 11, .height = 9}, + Rect{.base = Point{.x = 227, .y = 38}, .width = 11, .height = 8}, + Rect{.base = Point{.x = 192, .y = 0}, .width = 1, .height = 44}, + Rect{.base = Point{.x = 239, .y = 0}, .width = 1, .height = 43}, + Rect{.base = Point{.x = 273, .y = 48}, .width = 45, .height = 16}, + Rect{.base = Point{.x = 274, .y = 65}, .width = 12, .height = 14}, + Rect{.base = Point{.x = 306, .y = 64}, .width = 13, .height = 15}, + Rect{.base = Point{.x = 279, .y = 41}, .width = 35, .height = 5}, + Rect{.base = Point{.x = 288, .y = 32}, .width = 16, .height = 8}, + Rect{.base = Point{.x = 289, .y = 26}, .width = 14, .height = 6}, +}; + +pub const triggers = [_]Trigger{ + Trigger{.aura = Rect{.base = Point{.x = 16, .y = 96}, .width = 16, .height = 20}, .direction = Direction.Up, .dialogue = "Test message!"}, // 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 = 208, .y = 1}, .width = 7, .height = 23}, .direction = Direction.Up, .dialogue = "Kahsis' Edge"}, // high sign + Trigger{.aura = Rect{.base = Point{.x = 145, .y = 272}, .width = 13, .height = 25}, .direction = Direction.Up, .dialogue = "Check the\ndungeons!"}, // Garden Sign +}; + +pub const start_point = Point{ .x = 32, .y = 32 }; + diff --git a/src/sh0rk.zig b/src/sh0rk.zig index 559203e..715de15 100644 --- a/src/sh0rk.zig +++ b/src/sh0rk.zig @@ -1,7 +1,7 @@ pub const Point = packed struct { - x: i32, - y: i32, - pub fn init(x: i32, y: i32) @This() { + x: u16, + y: u16, + pub fn init(x: u16, y: u16) @This() { return @This() { .x = x, .y = y, @@ -15,9 +15,9 @@ pub const Point = packed struct { pub const Rect = packed struct { base: Point, - width: i32, - height: i32, - pub fn init(base: Point, width: i32, height: i32) @This() { + width: u8, + height: u8, + pub fn init(base: Point, width: u8, height: u8) @This() { return @This() { .base = base, .width = width, diff --git a/src/wasm4.zig b/src/wasm4.zig index 3b51d26..09925c8 100644 --- a/src/wasm4.zig +++ b/src/wasm4.zig @@ -138,7 +138,6 @@ pub const BlitFlags = packed struct { /// Copies pixels to the framebuffer. pub fn blit(sprite: []const u8, x: u32, y: u32, width: u32, height: u32, flags: BlitFlags) void { - raw_api.blit(sprite.ptr, x, y, width, height, @bitCast(u32, flags)); }