29 lines
677 B
Lua
29 lines
677 B
Lua
Wall = Object:extend()
|
|
|
|
function Wall:new(x, y, w, h, lifetime)
|
|
self.x = x
|
|
self.y = y
|
|
self.w = w --width of wall
|
|
self.h = h --height of wall
|
|
self.lifetime = lifetime
|
|
end
|
|
|
|
function Wall:update(dt)
|
|
--slowly decrease the lifetime of the wall
|
|
self.lifetime = self.lifetime - dt
|
|
--delete wall after lifetime is up
|
|
if self.lifetime <= 0 then
|
|
for i, v in ipairs(Walls) do
|
|
if v == self then --if the wall is the same as the wall we want to delete
|
|
table.remove(Walls, i)
|
|
end
|
|
end
|
|
end
|
|
end
|
|
|
|
function Wall:draw()
|
|
local rectangleColor = { 1, 1, 1 }
|
|
love.graphics.setColor(rectangleColor) --white
|
|
love.graphics.rectangle("fill", self.x, self.y, self.w, self.h)
|
|
end
|