Enemy = Object:extend()

function Enemy:new(x, y, image, speed)
	self.image = love.graphics.newImage(image)
	self.x = x
	self.y = y
	self.speed = speed
	self.width = self.image:getWidth()
	self.height = self.image:getHeight()
end

function Enemy:update(dt)
	--check if enemy has touched the wall and bouce back
	if self.x < 0 then
		self.x = 0
		self.speed = -self.speed
	elseif self.x + self.width > love.graphics.getWidth() then
		self.x = love.graphics.getWidth() - self.width
		self.speed = -self.speed
	end
end

function Enemy:draw()
	love.graphics.draw(self.image, self.x, self.y)
end
