Why is a “main” game loop necessary for developing a game?

前端 未结 11 1901
自闭症患者
自闭症患者 2020-12-23 13:52

I find that most game development requires a main game loop, but I don\'t know why it\'s necessary. Couldn\'t we implement an event listener and respond to every user action

11条回答
  •  情书的邮戳
    2020-12-23 14:22

    The main loop calls the event listener. If you are lucky enough to have an event-driven operating system or window manager, the event loop resides there. Otherwise, you write a main loop to mediate the "impedance mismatch" between an system-call interfaces that is based on I/O, poll, or select, and a traditional event-driven application.

    P.S. Since you tagged your question with functional-programming, you might want to check out Functional Reactive Programming, which does a great job connecting high-level abstractions to low-level, event-based implementations.

提交回复
热议问题