-- ===================================================================== -- lib-core.render — Tile-Grid Rendering (P.0) -- See: meta/docs/superpowers/specs/2026-05-09-p0-lib-render-design.md -- -- Scope: colored-quads only. Texture-rendering, PROTOTYPE-Lib-Pattern, -- camera, layers, post-processing, parallax, shaders, hot-reload — -- alle DEPRECATED-MVP, kommen in späteren Slices. -- ===================================================================== local maps = require("lib-core.maps") local FALLBACK_COLOR = {255, 0, 255} -- magenta — "missing color" debug-marker -- Reads tile-color from TileType-table; fallback to magenta if missing or malformed. local function tile_color(tile_type) local c = tile_type.color if type(c) ~= "table" or #c < 3 then return FALLBACK_COLOR end return c end local M = {} -- Iterates current (or specified) map's tiles, draws a colored rect per tile. -- Must be called from inside a render hook (engine.render.* enforces this). -- Returns the number of tiles drawn (for smoke verification + debug). function M.draw_map(map_id) local size = maps.size(map_id) local tile_size = maps.tile_size(map_id) local count = 0 for ty = 0, size.h - 1 do for tx = 0, size.w - 1 do local t = maps.tile_at(map_id, tx, ty) if t ~= nil then local c = tile_color(t) local color = engine.render.rgb(c[1], c[2], c[3]) engine.render.draw_rect( tx * tile_size, ty * tile_size, tile_size, tile_size, color) count = count + 1 end end end return count end -- Forward-compat stubs for later slices (kept as comments to avoid table-pollution): -- DEPRECATED-MVP: function M.draw_sprites(...) -- texture-slice -- DEPRECATED-MVP: function M.set_camera(camera) -- lib-core.camera slice -- DEPRECATED-MVP: function M.push_layer(name, order) -- multi-layer slice -- DEPRECATED-MVP: function M.register_pass(...) -- post-processing slice (spec §6) -- DEPRECATED-MVP: function M.set_clear_color(rgb) -- per-layer clear-color (spec §4) return M