From 982e54790e747c5ed5137c14006a44be4afcd9df Mon Sep 17 00:00:00 2001 From: Eltrac Date: Fri, 14 Mar 2025 09:06:36 +0800 Subject: refactor: seperate object placement initializers --- objects/Obstacle.lua | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'objects/Obstacle.lua') diff --git a/objects/Obstacle.lua b/objects/Obstacle.lua index ef83a5b..2152722 100644 --- a/objects/Obstacle.lua +++ b/objects/Obstacle.lua @@ -20,6 +20,14 @@ function Obstacle:new(name, location, body) return obj end +function Obstacle:placeInRoom(room) + local offset = self.w + G.player.r*2 + config.summonMargin + if not self.x or not self.y then + self.x, self.y = room:getLocation(self.presetLocation or "random", offset) + end + G.BodyLifeCycleManager:create(self, { self.w, self.h }, "static") +end + function Obstacle:update(dt) -- nothing yet end -- cgit v1.2.3