BG = Object:extend()

function BG:new(x, y, speed, img)
	self.image = love.graphics.newImage(img)
	self.speed = speed
	self.x = x
	self.y = y

	self.width = self.image:getWidth()
end

function BG:update(dt)
	self.x = self.x - (self.speed * dt)
	-- If the background goes off-screen, reset its position to loop
	if self.x + self.width < 0 then
		self.x = self.x + self.width
	elseif self.x > 0 then
		self.x = self.x - self.width
	end
end

function BG:draw()
	love.graphics.draw(self.image, self.x, self.y)
	love.graphics.draw(self.image, self.x + self.width, self.y)
end
