move maps to their own folder

Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
Cadey Ratio 2022-07-01 13:19:50 -04:00
parent fa3824f09f
commit 3c55e17626
4 changed files with 37 additions and 113 deletions

View File

@ -20,113 +20,7 @@ export fn start() void {
palette.mist();
}
const Tile = packed struct {
x: u4,
y: u4,
};
pub const map = [100]Tile{
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 7, .y = 1},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 7, .y = 3},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2},
Tile{.x = 0, .y = 0},
Tile{.x = 1, .y = 0},
Tile{.x = 2, .y = 0},
Tile{.x = 3, .y = 0},
Tile{.x = 1, .y = 0},
Tile{.x = 7, .y = 4},
Tile{.x = 3, .y = 0},
Tile{.x = 1, .y = 0},
Tile{.x = 2, .y = 0},
Tile{.x = 3, .y = 0},
Tile{.x = 5, .y = 0},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 1, .y = 2},
Tile{.x = 9, .y = 4},
Tile{.x = 2, .y = 2},
Tile{.x = 5, .y = 1},
Tile{.x = 1, .y = 2},
Tile{.x = 9, .y = 4},
Tile{.x = 2, .y = 2},
Tile{.x = 9, .y = 4},
Tile{.x = 2, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 5, .y = 2},
Tile{.x = 0, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 1, .y = 2},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 5, .y = 0},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 1, .y = 2},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 9, .y = 4},
Tile{.x = 1, .y = 4},
Tile{.x = 9, .y = 4},
};
const map = @import("./maps/testmap.zig").map;
fn drawMap() !void {
w4.m.colors.* = .{
@ -136,7 +30,6 @@ fn drawMap() !void {
._3 = .p3,
};
for (map) |tile, i| {
var x: u32 = i % 10;
var y: u32 = i / 10;

15
src/maps/testmap.zig Normal file
View File

@ -0,0 +1,15 @@
const Tile = @import("../sh0rk.zig").Tile;
pub const map = [100]Tile{
Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 7, .y = 1}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2},
Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 7, .y = 3}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 8, .y = 2}, Tile{.x = 0, .y = 0},
Tile{.x = 1, .y = 0}, Tile{.x = 2, .y = 0}, Tile{.x = 3, .y = 0}, Tile{.x = 1, .y = 0}, Tile{.x = 7, .y = 4}, Tile{.x = 3, .y = 0}, Tile{.x = 1, .y = 0}, Tile{.x = 2, .y = 0}, Tile{.x = 3, .y = 0}, Tile{.x = 5, .y = 0},
Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 2}, Tile{.x = 5, .y = 1},
Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 2, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 5, .y = 2},
Tile{.x = 0, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 5, .y = 0},
Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 2}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 9, .y = 4}, Tile{.x = 1, .y = 4}, Tile{.x = 9, .y = 4},
};

View File

@ -39,4 +39,9 @@ pub const Direction = enum(u2) {
Down,
Left,
Right,
};
pub const Tile = packed struct {
x: u4,
y: u4,
};

View File

@ -1,21 +1,32 @@
if (Deno.args.length !== 1) {
console.log("Usage: ./genmap.js <path-to-map-file>");
if (Deno.args.length !== 2) {
console.log("Usage: ./genmap.js <path-to-map-file> <output-fname>");
Deno.exit(1);
}
const mapFile = Deno.args[0];
const outFname = Deno.args[1];
var out = "";
const data = await Deno.readTextFile(mapFile);
const map = JSON.parse(data);
let layer = map.layers[0];
console.log(`pub const map = [${layer.data.length}]Tile{`);
out += `const Tile = @import("../sh0rk.zig").Tile;\n\n`;
out += `pub const map = [${layer.data.length}]Tile{\n `;
layer.data.forEach((tile, index) => {
tile -= 1;
const tileY = Math.trunc(tile / layer.height);
const tileX = tile % layer.width;
console.log(` Tile{.x = ${tileX}, .y = ${tileY}},`);
out += ` Tile{.x = ${tileX}, .y = ${tileY}},`;
if (index % 10 === 0) {
out += "\n ";
}
});
console.log("};");
out += "\n};\n";
await Deno.writeTextFile(outFname, out);