make map generated code look better
Signed-off-by: Christine Dodrill <me@christine.website>
This commit is contained in:
parent
e1feccb8f9
commit
061d352140
|
@ -4,8 +4,7 @@ const Rect = sh0rk.Rect;
|
|||
const Tile = sh0rk.Tile;
|
||||
|
||||
pub const data = [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 = 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},
|
||||
|
@ -18,6 +17,7 @@ pub const data = [100]Tile{
|
|||
};
|
||||
|
||||
pub const coll = [2]Rect{
|
||||
Rect{.base = Point{.x = 0, .y = 80}, .width = 160, .height = 80}, Rect{.base = Point{.x = 80, .y = 48}, .width = 16, .height = 32},
|
||||
Rect{.base = Point{.x = 0, .y = 80}, .width = 160, .height = 80},
|
||||
Rect{.base = Point{.x = 80, .y = 48}, .width = 16, .height = 32},
|
||||
};
|
||||
|
||||
|
|
|
@ -26,8 +26,10 @@ tiles.data.forEach((tile, index) => {
|
|||
const tileY = Math.trunc(tile / tiles.height);
|
||||
const tileX = tile % tiles.width;
|
||||
out += `Tile{.x = ${tileX}, .y = ${tileY}},`;
|
||||
if (index % 10 === 0) {
|
||||
if (index !== 0 && index % 10 === 0) {
|
||||
out += "\n ";
|
||||
} else {
|
||||
out += " ";
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -44,10 +46,10 @@ if (map.layers.length >= 2) {
|
|||
const width = Math.round(obj.width);
|
||||
const height = Math.round(obj.height);
|
||||
|
||||
out += ` Rect{.base = Point{.x = ${x}, .y = ${y}}, .width = ${width}, .height = ${height}},`;
|
||||
out += ` Rect{.base = Point{.x = ${x}, .y = ${y}}, .width = ${width}, .height = ${height}},\n`;
|
||||
});
|
||||
|
||||
out += "\n};\n\n";
|
||||
out += "};\n\n";
|
||||
}
|
||||
|
||||
await Deno.writeTextFile(outFname, out);
|
||||
|
|
Loading…
Reference in New Issue