diff --git a/obj/Area.lua b/obj/Area.lua index eac750a..db309d5 100644 --- a/obj/Area.lua +++ b/obj/Area.lua @@ -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