summaryrefslogtreecommitdiff
path: root/objects/Obstacle.lua
blob: 2c546506ca014d85130a47b07015c2a6332429ec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require "data.directions"

local Obstacle = {}
Obstacle.__index = Obstacle

function Obstacle:new(name, location)
    local obj = {
        objectType = "obstacle",
        name = name,
        presetLocation = (type(location) == "string" and location) or nil,
        x = (type(location) == "table" and location.x) or nil,
        y = (type(location) == "table" and location.y) or nil,
        w = 50,
        h = 50,
    }

    setmetatable(obj, Obstacle)

    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

return Obstacle