Since you are asking for advice, I will comment on the implementation of events.
A good way to do that is making your game objects able to
emit and
observes signals.
A signal can be nearly anything, for example a string. "Emitting" can be simply calling a function that stores the signal on a private table. And observing is calling another function that says "when this signal appears on the table of signals, call this function". On each update cycle, the table of signals is parsed, the functions inside the table of functions are invoked accordingly, and then the signals are erased.
Here's an example of this pattern for an hypothetical "pause button".
Code: Select all
observe_signal("PAUSE", function() pause_enemy(enemy1) end)
observe_signal("PAUSE", function() pause_enemy(enemy2) end)
observe_signal("PAUSE", function() pause_player(player) end)
...
function pause_button_pressed()
emit_signal("PAUSE")
end
I implemented such a system with
Beholder, but I have to re-do now that I've updated middleclass. I'll probably separate it from it to make it a bit more lightweight.