Rearrange tiles, add one way platform tiles

- Update autotile to work based off of offset
- Update wired.ldtk to use new tiles
- Regenerate tiles.zig
- Remove hard-coded autotiles
master
Louis Pearson 2022-08-04 14:41:15 -06:00
parent 0c79bfe575
commit 8d3f69af03
5 changed files with 1046 additions and 1063 deletions

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 730 B

After

Width:  |  Height:  |  Size: 654 B

File diff suppressed because one or more lines are too long

View File

@ -58,57 +58,18 @@ pub fn start() !void {
.level = level, .level = level,
.map = &map, .map = &map,
.circuit = &circuit, .circuit = &circuit,
.tileset = world.AutoTileset.initFull(&.{ .tileset = world.AutoTileset.initOffsetFull(113),
35, // Island .conduit = world.AutoTileset.initOffsetFull(97),
51, // North .plug = world.AutoTileset.initOffsetCardinal(17),
52, // West
55, // West-North
50, // East
53, // East-North
19, // East-West
54, // East-West-North
49, // South
20, // South-North
23, // South-West
39, // South-West-North
21, // South-East
37, // South-East-North
22, // South-East-West
0, // South-East-West-North
}),
.conduit = world.AutoTileset.initFull(&.{
42, // Island
58, // North
59, // West
41, // West-North
57, // East
40, // East-North
26, // East-West
73, // East-West-North
56, // South
27, // South-North
25, // South-West
74, // South-West-North
24, // South-East
75, // South-East-North
72, // South-East-West
43, // South-East-West-North
}),
.plug = world.AutoTileset.initCardinal(&.{
45, // North
46, // West
47, // East
44, // South
}, 2),
.switch_off = world.AutoTileset.initSwitches(&.{ .switch_off = world.AutoTileset.initSwitches(&.{
32, // South-North 29, // South-North
29, // South-West-North 25, // South-West-North
31, // South-East-North 27, // South-East-North
}, 2), }, 2),
.switch_on = world.AutoTileset.initSwitches(&.{ .switch_on = world.AutoTileset.initSwitches(&.{
48, // South-North 30, // South-North
28, // South-West-North 26, // South-West-North
30, // South-East-West 28, // South-East-West
}, 2), }, 2),
}); });
} }

View File

@ -111,20 +111,22 @@ pub const AutoTile = packed struct {
}; };
pub const AutoTileset = struct { pub const AutoTileset = struct {
lookup: []const u8, lookup: []const u8 = "",
offset: u8 = 0,
kind: enum { kind: enum {
Cardinal, Cardinal,
Switches, Switches,
Full, Full,
OffsetFull,
OffsetCardinal,
}, },
default: u8, default: u8 = 0,
pub fn initFull(table: []const u8) AutoTileset { pub fn initFull(table: []const u8) AutoTileset {
std.debug.assert(table.len == 16); std.debug.assert(table.len == 16);
return AutoTileset{ return AutoTileset{
.lookup = table, .lookup = table,
.kind = .Full, .kind = .Full,
.default = 0,
}; };
} }
@ -146,16 +148,40 @@ pub const AutoTileset = struct {
}; };
} }
pub fn initOffsetFull(offset: u8) AutoTileset {
// std.debug.assert(offset < 128 - 16);
return AutoTileset{
.offset = offset,
.kind = .OffsetFull,
};
}
pub fn initOffsetCardinal(offset: u8) AutoTileset {
// std.debug.assert(offset < 128 - 4);
return AutoTileset{
.offset = offset,
.kind = .OffsetCardinal,
};
}
pub fn find(tileset: AutoTileset, autotile: AutoTile) u8 { pub fn find(tileset: AutoTileset, autotile: AutoTile) u8 {
const autoint = autotile.to_u4(); const autoint = autotile.to_u4();
switch (tileset.kind) { switch (tileset.kind) {
.Full => return tileset.lookup[autoint], .Full => return tileset.lookup[autoint],
.Cardinal => switch (autoint) { .OffsetFull => return tileset.offset + autoint,
0b0001 => return tileset.lookup[0], .Cardinal, .OffsetCardinal => {
0b0010 => return tileset.lookup[1], const index: u8 = switch (autoint) {
0b0100 => return tileset.lookup[2], 0b0001 => 0,
0b1000 => return tileset.lookup[3], 0b0010 => 1,
0b0100 => 2,
0b1000 => 3,
else => return tileset.default, else => return tileset.default,
};
if (tileset.kind == .Cardinal) {
return tileset.lookup[index];
} else {
return tileset.offset + index;
}
}, },
.Switches => switch (autoint) { .Switches => switch (autoint) {
0b1001 => return tileset.lookup[0], 0b1001 => return tileset.lookup[0],