Lua and C++: separation of duties

后端 未结 3 1264
青春惊慌失措
青春惊慌失措 2021-02-08 04:22

Please help to classify ways of organizing C++/Lua game code and to separate their duties. What are the most convenient ways, which one do you use?

For example, Lua can

3条回答
  •  借酒劲吻你
    2021-02-08 05:16

    I propose this classification:

    1. Extreme variant: Lua scripts control everything (game logic, graphics, AI etc.). Even more: script works as a host-program, owns game loop. Some engines do such thing. Ba-ad thing: no separation of duties at all and no script safety.

    2. Lua scripts maintain game state and process game logic. Probably scripts are called at each game loop iteration.

    3. Lua scripts are rarely used for initializations, configurations, callbacks. A host program provides (binds) a very minimalistic interface for the scripts. So scripts are built from such well-designed and provided blocks.

提交回复
热议问题