summaryrefslogtreecommitdiff
path: root/objects/Obstacle.lua
diff options
context:
space:
mode:
authorEltrac <hi@guhub.cn>2025-03-14 09:06:36 +0800
committerEltrac <hi@guhub.cn>2025-03-14 09:06:36 +0800
commit982e54790e747c5ed5137c14006a44be4afcd9df (patch)
treed3bd7d9991382439de2352566a95cc21db055c05 /objects/Obstacle.lua
parent78b207c925554d45de804c8e85efa23bbc32d8d4 (diff)
refactor: seperate object placement initializers
Diffstat (limited to 'objects/Obstacle.lua')
-rw-r--r--objects/Obstacle.lua8
1 files changed, 8 insertions, 0 deletions
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