add area destroy function

This commit is contained in:
yuki 2025-11-11 04:55:10 -03:00
parent 9f389e5232
commit 8ad931f33b

View file

@ -32,6 +32,18 @@ function Area:draw()
for _, game_object in ipairs(self.game_objects) do game_object:draw() end
end
---Destroys area
function Area:destroy()
for i = #self.game_objects, 1, -1 do
local game_object = self.game_objects[i]
game_object:kill()
table.remove(self.game_objects, i)
end
self.game_objects = {}
if self.world then self.world = nil end
end
---Adds game object to area
---@param game_object_type string name of game object's class
---@param x number|nil horizontal position