I made a little module of convenience functions to help draw lines, shapes, and text for visual debugging. The render “draw_line” and “draw_text” messages are really long and cumbersome to type, so this wraps them up and makes things simple. It’s not an exhaustive shape-drawing library, just enough to draw a few different kinds of indicators and things.
I don’t know if this is a known issue or it is an issue only on my mac. But text is not aligned with the other graphic elements. It seems like text is not behaving well with window size changing. Here is a screenshot:
Demo is meant for demonstration so not really an issue. You can position debug draw text however you want but for a real game you want to use labels / gui text anyway.
function M.text(text, x, y, color)
local scale = window.get_display_scale()
color = color or M.default_color
if M.COLORS[color] then color = M.COLORS[color] end
V1.x, V1.y = x * scale, y * scale
TEXTMSGDATA.text, TEXTMSGDATA.position, TEXTMSGDATA.color = text, V1, color
msg.post("@render:", "draw_debug_text", TEXTMSGDATA)
end
The display scale should obviously be cached and not called every time.