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 lerp(a, b, t) return a + (b - a) * t 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, 0, 0 } -- Starting color (red) love.graphics.setColor(rectangleColor) --white love.graphics.rectangle("fill", self.x, self.y, self.w, self.h) end