SpiderWebEntity::SpiderWebEntity(float x, float y, bool isFromPlayer)
  : EnemyEntity (ImageManager::getInstance().getImage(IMAGE_SPIDER_WEB), x, y)
{
  imagesProLine = 20;
  if (isFromPlayer) type = ENTITY_ENEMY_NC;
  else type = ENTITY_ENEMY_INVOCATED;
  enemyType = EnemyTypeSpiderWeb;
  movingStyle = movFlying;
  bloodColor = BloodNone; // web don't bleed
  deathFrame = FRAME_CORPSE_SPIDER_WEB;

  this->isFromPlayer = isFromPlayer;

  age = 0.0f;

  frame = 0;

  setVelocity(Vector2D(80 + rand()% 500));
  width = 128.0f;
  height = 128.0f;
  sprite.setOrigin(64.0f, 64.0f);
  viscosity = 0.97f;
  hp = 40;
  hpMax = 40;

  resistance[ResistanceFrozen] = ResistanceImmune;
  resistance[ResistanceRecoil] = ResistanceImmune;
  resistance[ResistanceFire] = ResistanceVeryLow;
  resistance[ResistanceStone] = ResistanceVeryLow;
  resistance[ResistancePoison] = ResistanceImmune;

  canExplode = false;

  if (!testEntityInMap()) isDying = true;
}
RockMissileEntity::RockMissileEntity(float x, float y, int rockType)
  : EnemyEntity (ImageManager::getInstance().getImage(IMAGE_CYCLOP), x, y)
{

  Vector2D targetPos = game().getPlayerPosition();
  imagesProLine = 20;
  collisionDirection = -1;
  enemyType = EnemyTypeRockMissile;
  movingStyle = movFlying;
  bloodColor = BloodNone; // stones don't bleed
  hasCollided = false;

  age = 0.0f;

  this->rockType = rockType;

  if (rockType == 0)
  {
    creatureSpeed = 500.0f;
    hp = 12;
    meleeDamages = 5;
    frame = 18;
  }
  else
  {
    creatureSpeed = 450.0f;
    hp = 24;
    meleeDamages = 8;
    frame = 38;
  }

  setVelocity(Vector2D(x, y).vectorNearlyTo(targetPos, creatureSpeed, 0.4f));
  canExplode = false;
  if (y < TILE_HEIGHT) this->y = TILE_HEIGHT;
  if (!testEntityInMap()) isDying = true;
  resistance[ResistancePoison] = ResistanceImmune;
}