3 ms·
In Javascript, you have to install event handlers. There is no control when they are executed, which is a problem. When writing a game engine, you typically cr
by jstimpfle 10y ago
In Javascript, you have to install event handlers. There is no control when they are executed, which is a problem.
When writing a game engine, you typically create events yourself at the top of the game loop (reading the input sources in a non-blocking fashion). You have better control what handler is called and when, but what handler should be called probably still shouldn't be decided in a central location. So I figure your object-based approach is a good solution. (The individual handlers can rely on the fact that they are only called at the start of the loop).
I realize a Javascript app could easily emulate the game loop style by letting handlers write to a queue.