I think going for C/C++ was a bit overwhelming after all.
I tried to find ways to make Lua work, and I found
Love2d.
It allows for lots of things that Bizhawk couldn't do (like image manipulation and sound) and allows to convert the program into an executable later.
I'm in the process of porting my Bizhawk script to it. It has been difficult but I'm getting results:
Unfortunately I had to throw some things out for now (fading, 3-sec countdown, input config). My code is a mess and I want to simplify it a lot before I add to it anything new.
Love2d uses 3 functions
love.load() which is called once at the start, used for declaring everything
love.update(), called once per frame, used for logic etc.
love.draw(), called once per frame, used for drawing stuff
My script was structured in such a way that logic and drawing was mixed (this is an example):
Language: Lua
game = { -- game[mode]
[0]= function()
-- stuff
end
[1]= function()
-- other stuff
end
[2]=function()
-- the actual game
playerMove()
wallCollision()
drawMap()
drawPlayer()
[3]=function()
-- ...
So I had to split
game into two:
game and
draw.
I call game[mode]() in love.update()
and draw[mode]() in love.draw()
I'm not happy with this structure, but because of the complication of this 3 function system, it's the only way to make it work. Maybe I will find a better way soon.
I'm also a bit worried about the thing I read in one tutorial, about
delta times.
Ideally the game runs at the same constant FPS for everyone and I can do logic based on frames. But in practice, it seems you need to account for FPS differences and include delta time in most calculations. Maybe I will not worry about it for now...