I have a game loop that simply iterates through every entity and calls entity.update()
class Engine {
protected entities: IUpdateable[]
update() {
GlobalTime.tick(this)
for (let entity of this.entities) {
entity.update()
}
}
I need to accept user input, but without requiring the game loop to pause and wait, like the following code would do
update() {
getUserInput() // will result in async-await like behavior, pausing until user input
GlobalTime.tick(this)
for (let entity of this.entities) {
entity.update()
}
}
What is the standard way to implement optional asynchronous user-input with a continuous game loop? Is it just to have an .events array that is checked every frame, resets every frame, that the frontend can optionally append user input to?