Attempt to solve invisible rocks

They are on the map, but the wrong tile is getting selected
master
Louis Pearson 2022-08-05 00:18:22 -06:00
parent 638440f619
commit 83bd4d9aec
3 changed files with 10 additions and 10 deletions

View File

@ -2742,7 +2742,7 @@
1,1,1,1,1,1,1,1,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,3,3,0,0,1,1,1,
1,1,0,0,0,1,0,0,0,0,1,1,1,0,0,0,0,1,1,1,1,1,0,0,0,1,1,3,0,0,1,1,1,0,0,
3,3,1,1,1,1,1,0,0,0,0,0,0,0,0,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,0,0,3,3,
1,1,1,3,3,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,2,1,1,1,1,1,
1,1,1,3,3,0,0,0,2,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,2,0,1,1,1,1,1,
1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
],
"autoLayerTiles": [
@ -2880,7 +2880,6 @@
{ "px": [96,72], "src": [16,56], "f": 0, "t": 114, "d": [20,192] },
{ "px": [48,120], "src": [16,56], "f": 0, "t": 114, "d": [20,306] },
{ "px": [136,144], "src": [0,56], "f": 0, "t": 112, "d": [85,377] },
{ "px": [152,144], "src": [0,56], "f": 0, "t": 112, "d": [85,379] },
{ "px": [144,144], "src": [8,56], "f": 0, "t": 113, "d": [90,378] },
{ "px": [144,136], "src": [64,56], "f": 0, "t": 120, "d": [91,358] },
{ "px": [24,48], "src": [8,16], "f": 0, "t": 33, "d": [125,123] },

View File

@ -26,15 +26,15 @@ pub const TileData = union(enum) {
pub fn toByte(data: TileData) u8 {
switch (data) {
.tile => |int| return 1 | (int << 1),
.tile => |int| return 0b0000_0001 | (int << 1),
.flags => |flags| return (@intCast(u7, @boolToInt(flags.solid)) << 1) | (@intCast(u7, flags.circuit) << 2),
}
}
pub fn fromByte(byte: u8) TileData {
const is_tile = (1 & byte) > 0;
const is_tile = (0b0000_0001 & byte) > 0;
if (is_tile) {
const tile = @intCast(u7, (~@as(u7, 1) & byte) >> 1);
const tile = @intCast(u7, (0b1111_1110 & byte) >> 1);
return TileData{ .tile = tile };
} else {
const is_solid = (0b0000_0010 & byte) > 0;

View File

@ -150,8 +150,6 @@ fn make(step: *std.build.Step) !void {
if (circuit_layer == null) return error.MissingCircuitLayer;
if (collision_layer == null) return error.MissingCollisionLayer;
std.log.warn("Layers found", .{});
const circuit = circuit_layer.?;
const collision = collision_layer.?;
@ -175,19 +173,22 @@ fn make(step: *std.build.Step) !void {
const tiles = level.tiles.?;
// Add straight tile data
// Add unchanged tile data
for (collision.autoLayerTiles) |autotile| {
const x = @divExact(autotile.px[0], collision.__gridSize);
const y = @divExact(autotile.px[1], collision.__gridSize);
const i = @intCast(usize, x + y * width);
tiles[i] = world.TileData{ .tile = @intCast(u7, autotile.t + 1) };
const sx = @divExact(autotile.src[0], collision.__gridSize);
const sy = @divExact(autotile.src[1], collision.__gridSize);
const t = sx + sy * 16 + 1;
tiles[i] = world.TileData{ .tile = @intCast(u7, t) };
}
// Add circuit tiles
for (circuit.intGridCsv) |cir64, i| {
const cir = @intCast(u4, cir64);
const col = collision.intGridCsv[i];
if (col < 2) {
if (col == 0 or col == 1) {
tiles[i] = world.TileData{ .flags = .{
.solid = col == 1,
.circuit = cir,