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 autotilesmaster
parent
0c79bfe575
commit
8d3f69af03
File diff suppressed because it is too large
Load Diff
BIN
assets/tiles.png
BIN
assets/tiles.png
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
|
@ -58,57 +58,18 @@ pub fn start() !void {
|
|||
.level = level,
|
||||
.map = &map,
|
||||
.circuit = &circuit,
|
||||
.tileset = world.AutoTileset.initFull(&.{
|
||||
35, // Island
|
||||
51, // North
|
||||
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),
|
||||
.tileset = world.AutoTileset.initOffsetFull(113),
|
||||
.conduit = world.AutoTileset.initOffsetFull(97),
|
||||
.plug = world.AutoTileset.initOffsetCardinal(17),
|
||||
.switch_off = world.AutoTileset.initSwitches(&.{
|
||||
32, // South-North
|
||||
29, // South-West-North
|
||||
31, // South-East-North
|
||||
29, // South-North
|
||||
25, // South-West-North
|
||||
27, // South-East-North
|
||||
}, 2),
|
||||
.switch_on = world.AutoTileset.initSwitches(&.{
|
||||
48, // South-North
|
||||
28, // South-West-North
|
||||
30, // South-East-West
|
||||
30, // South-North
|
||||
26, // South-West-North
|
||||
28, // South-East-West
|
||||
}, 2),
|
||||
});
|
||||
}
|
||||
|
|
|
@ -111,20 +111,22 @@ pub const AutoTile = packed struct {
|
|||
};
|
||||
|
||||
pub const AutoTileset = struct {
|
||||
lookup: []const u8,
|
||||
lookup: []const u8 = "",
|
||||
offset: u8 = 0,
|
||||
kind: enum {
|
||||
Cardinal,
|
||||
Switches,
|
||||
Full,
|
||||
OffsetFull,
|
||||
OffsetCardinal,
|
||||
},
|
||||
default: u8,
|
||||
default: u8 = 0,
|
||||
|
||||
pub fn initFull(table: []const u8) AutoTileset {
|
||||
std.debug.assert(table.len == 16);
|
||||
return AutoTileset{
|
||||
.lookup = table,
|
||||
.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 {
|
||||
const autoint = autotile.to_u4();
|
||||
switch (tileset.kind) {
|
||||
.Full => return tileset.lookup[autoint],
|
||||
.Cardinal => switch (autoint) {
|
||||
0b0001 => return tileset.lookup[0],
|
||||
0b0010 => return tileset.lookup[1],
|
||||
0b0100 => return tileset.lookup[2],
|
||||
0b1000 => return tileset.lookup[3],
|
||||
else => return tileset.default,
|
||||
.OffsetFull => return tileset.offset + autoint,
|
||||
.Cardinal, .OffsetCardinal => {
|
||||
const index: u8 = switch (autoint) {
|
||||
0b0001 => 0,
|
||||
0b0010 => 1,
|
||||
0b0100 => 2,
|
||||
0b1000 => 3,
|
||||
else => return tileset.default,
|
||||
};
|
||||
if (tileset.kind == .Cardinal) {
|
||||
return tileset.lookup[index];
|
||||
} else {
|
||||
return tileset.offset + index;
|
||||
}
|
||||
},
|
||||
.Switches => switch (autoint) {
|
||||
0b1001 => return tileset.lookup[0],
|
||||
|
|
Loading…
Reference in New Issue