I've been focusing on menus lately. At first I found them intimidating but I'm starting to get the hang of it now. As a web developer, creating menus by drawing pixels is very weird. I know this is just how games work, though.
Still, I'm tempted to start breaking my menus into reusable components like in Vue.js. For example, I have multiple menus which contain a grid of items the player may highlight and select. I could see having an API like
-- Example menu with reusable components
local title_bar = require("scripts/ui/components/title_bar")
local item_picker = require("scripts/ui/components/item_picker")
local menu = {
components = {
title_bar:new({bg_color={0,0,0}, text="Inventory"),
item_picker:new({row=3, col=5, gutter=8})
}
}
function menu:on_draw()
for _, component in ipairs(self.components) do
component:draw(self)
end
end
return menu
idk, I haven't fully thought this through obviously, but I'd love to see some sort of component-based design in action. I haven't fully worked out how this needs to happen in Lua.