Enemy = class(Object, function(o, x, y, w, h)
	Object.init(o,x,y,w,h)
	o.freeze = 0
	-- add to the box2d world
	if box2d then
		o.b2d = BludBox2dRect(box2d, o.pos.x+o.w/2, o.pos.y+o.h/2, o.w/2, o.h/2, 1, 0.4, 0.4, true)
		o.b2d:setData(o)
	end	
end)
function Enemy:update()
	Object.update(self)
	if self.b2d then
		if self.alive then
			self.b2d:setPosition(self.pos.x+self.w/2, self.pos.y+self.h/2)
		elseif self.killb2d then
			self.b2d:destroy();
			self.killb2d = false;
		end
	end
end
function Enemy:sync()
	if self.freeze > 0 then self.freeze = self.freeze - 1; return false end
	return true
end
function Enemy:hit(damage, damageType)
	if not damageType then
		self.health = self.health - damage
		if self.health <= 0 then
			player.achievements:killedEnemy()
			self:kill(true)
		end
	elseif damageType == "freeze" then
		self.freeze = self.freeze + damage
	end
	-- print(self.health/game_settings[self.settingName.."health"])
	if self.healthbar then
		self.healthbar:setValue(self.health/game_settings[self.settingName.."health"])
	end
end
function Enemy:isFrozen()
	return self.freeze > 0
end