I really like Lua and such but I don't think that completely/automatically mirroring the c++ API 1 to 1 is a good idea.
Also there is LOVE which packs Box2D, PhysFS and some other things along graphics/input.
I'm semi interested in this because if I wanted to write a game in Lua I'd take LOVE not the c++ library I like.
But at the same time I like Lua and SFML and this is related to both.
Lua has convention of using strings as enums(and so do I in SFG unless it's bitflag enum).
It's a bit weird event is object, maybe it should be a table made by user and get filled with right fields and then you check them directly with . and compare with strings. Also it could be so that if type is key pressed then the event table has set field event.code, not event.key.code, because that's just side effect of needing struct for even union in c++.
if(event:type() == sfEventType.KeyReleased and event:key():code() == sfKey.Escape ) then window:close(); end
vs.
if event.type == "KeyReleased" and event.code == "Escape" then window:close() end
The second one looks much nicer IMO(I don't use semicolons or redundant parenthesis but that's not the point here).
Same for color and video mode, both are just few bytes of numbers, color could be a single number or four numbers and video mode could be replaced by 3 number args with one being optional.
math.random(256)-1
is same result and number of characters as
math.random(0,255)
but that one is more clear.
Maybe also creating preloader for SFML module and removing sf from front so it'd be possible to do:
local sf = require"SFMLua"
--use sf.ClassName just like a c++ namespace
Perhaps there could be even some Lua code to go along the binding, for example, iterator for events.
event = sfEvent.new();
while window:pollEvent(event) do
-- do stuff...
end
vs(iterative + non c++ events).
for event in window:iterateEvents() do
-- do stuff...
end
Iterate events could be:
function iterateEvents(self)
local event = {}
return function()
if self:pollEvent(event) then return event end
end
end
I think.. I'm writing from memory
, I'm still lacking in Lua.