summaryrefslogtreecommitdiff
path: root/main.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-12 17:55:00 +0800
committerEltrac <hi@guhub.cn>2025-03-12 17:55:00 +0800
commit6b48551d59818b385200221f0a42afea0a3545d5 (patch)
treea3403b639567693f25462a5aaf74ffba8a42ccf3 /main.lua
parent4bfe8d7679bfce861c03cff728d1aa9f44efeff9 (diff)
fix: game crash when creating new body during world update
use a body lifecycle manager to create after world update is done
Diffstat (limited to 'main.lua')
-rw-r--r--main.lua7
1 files changed, 4 insertions, 3 deletions
diff --git a/main.lua b/main.lua
index a602cac..4076521 100644
--- a/main.lua
+++ b/main.lua
@@ -1,10 +1,9 @@
require "config"
require "utils.utils"
-
require "render.sprite"
require "render.speaker"
-
local map = require "logic.map"
+local bodyLifeCycleManager = require "utils.bodyLifecycleManager"
local controller = require "logic.controller"
local translator = require "i18n.translator"
@@ -21,6 +20,8 @@ function love.load()
-- initialize game state
initGame()
+ -- body life cycle manager
+ G.BodyLifeCycleManager = bodyLifeCycleManager.new()
-- set world callbacks
G.world:setCallbacks(onContact)
@@ -33,7 +34,7 @@ end
function love.update(dt)
-- game state updates
- local gameStates = { G.world, G.currentRoom, G.player }
+ local gameStates = { G.world, G.currentRoom, G.player, G.BodyLifeCycleManager }
for _, state in ipairs(gameStates) do
state:update(dt)
end