diff --git a/init.lua b/init.lua index 7d00aa6..723a844 100644 --- a/init.lua +++ b/init.lua @@ -339,6 +339,9 @@ end -- Internal: draw all cells in one layer using atlas-handle + UV sampling. -- (M.2: replaces per-tile texture_handle pattern with atlas-level handle.) +-- Magenta-placeholder color (RGBA8888 0xFF00FFFF) for missing-asset draw paths. +local MISSING_ASSET_COLOR = 0xFFFF00FF + local function draw_layer(m, layer_name) local layer = m.layers[layer_name] if not layer then return end @@ -351,11 +354,11 @@ local function draw_layer(m, layer_name) if gid ~= 0 then local atlas_idx, tile_id, rot_quad = decode_gid(gid) local atlas = m.atlases[atlas_idx + 1] - if atlas then + local px = x * ts + local py = y * ts + if atlas and atlas.diffuse_texture_handle then local tile = atlas.tiles[tile_id] - if tile then - local px = x * ts - local py = y * ts + if tile and tile.uv then local rot_deg = rot_quad * 90.0 engine.render.draw_sprite_transform( atlas.diffuse_texture_handle, @@ -366,7 +369,15 @@ local function draw_layer(m, layer_name) 0xFFFFFFFF, tile.uv.x, tile.uv.y, tile.uv.w, tile.uv.h ) + else + -- Tile-record missing or no uv: magenta placeholder. + engine.render.draw_rect(px, py, ts, ts, MISSING_ASSET_COLOR) end + else + -- Atlas not loaded (load_textures was never called, or asset + -- alias resolution returned nil): magenta placeholder so the + -- consumer sees the missing-asset visually instead of crashing. + engine.render.draw_rect(px, py, ts, ts, MISSING_ASSET_COLOR) end end end