/apps/demos/crawl: facing textures

This commit is contained in:
veclavtalica 2025-02-21 02:00:00 +03:00
parent b6347996f9
commit a020b92824
4 changed files with 37 additions and 0 deletions

BIN
apps/demos/crawl/data/assets/castledoors.png (Stored with Git LFS) Normal file

Binary file not shown.

BIN
apps/demos/crawl/data/assets/lever.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -24,9 +24,13 @@
X door
open_on_signal : sg_torch0
tile_texture : /assets/mossy_rock.png
face : horizon
face_texture : /assets/castledoors.png
/ lever
on_interact_emit : sg_torch0
tile_texture : /assets/mossy_rock.png
face : observer
face_texture : /assets/lever.png
@meta
-- Arbitrary sections could be defined with value pairs.

View File

@ -54,6 +54,33 @@ function render_dungeon(dungeon)
texture_region = { w = 128, h = 128 },
}
end
if dungeon.grid[y][x].face_texture ~= nil then
if dungeon.grid[y][x].face == "horizon" then
draw_quad {
texture = dungeon.grid[y][x].face_texture,
v3 = { x = y * 2, y = 2, z = x * 2 + 1 },
v2 = { x = y * 2, y = 0, z = x * 2 + 1 },
v1 = { x = y * 2 + 2, y = 0, z = x * 2 + 1 },
v0 = { x = y * 2 + 2, y = 2, z = x * 2 + 1 },
texture_region = { w = 64, h = 96 },
}
draw_quad {
texture = dungeon.grid[y][x].face_texture,
v3 = { x = y * 2 + 2, y = 2, z = x * 2 + 1 },
v2 = { x = y * 2 + 2, y = 0, z = x * 2 + 1 },
v1 = { x = y * 2, y = 0, z = x * 2 + 1 },
v0 = { x = y * 2, y = 2, z = x * 2 + 1 },
texture_region = { w = 64, h = 96 },
}
elseif dungeon.grid[y][x].face == "observer" then
draw_billboard {
texture = dungeon.grid[y][x].face_texture,
position = { x = y * 2 + 1, y = 1, z = x * 2 + 1 },
size = { x = 1, y = 1 },
}
end
end
end
end
end