Lua, game state and game loop

前端 未结 9 1291
慢半拍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:30

    My basic rule for lua is - or any script language in a game -

    • Anything that happens on every frame: c++
    • asynchronous events - user input - lua
    • synchronous game engine events - lua

    Basically, any code thats called at >33-100Hz (depending on frame rate) is C++ I try to invoke the script engine <10Hz.

    Based on any kind of actual metric? not really. but it does put a dividing line in the design, with c++ and lua tasks clearly delineated - without the up front delineation the per frame lua tasks will grow until they are bogging processing per frame - and then theres no clear guideline on what to prune.

提交回复
热议问题