Lua, game state and game loop

前端 未结 9 1299
慢半拍i
慢半拍i 2021-01-31 10:13
  1. Call main.lua script at each game loop iteration - is it good or bad design? How does it affect on the performance (relatively)?

  2. Maintain game state fro

9条回答
  •  长发绾君心
    2021-01-31 10:51

    Most of the performance will be lost through the binding between Lua and C++. A function call will actually need to be wrapped, and re-wrapped, and like that a couple of time usually. Pure Lua or pure C++ code is usually faster than mixed code (for small operations).

    Having said that, I personally didn't see any strong performance hit running a Lua script every frame.

    Usually scripting is good at high level. Lua has been used in famous games for the Bots (Quake 3) and for the User Interface (World of Warcraft). Used at high level Lua micro-threads come handy: The coroutines can save a lot (compared to real threads). For example to run some Lua code only once in a while.

提交回复
热议问题