void CEnemyZombie::Update( int backGroundX, int backGroundY ) { if (m_pickup != NULL) m_pickup->Update(backGroundX, backGroundY); if (!m_entity->IsVisible()) return; if (!m_entity->IsEnabled() && m_entity->IsOnScreen()) { CLasagne::GetInstance()->EnableEntity(&m_entity); } if (m_health <= 0) { m_speed = 0.0f; static const Uint32 fadeAfterDeath = 3000; if (SDL_GetTicks() - m_dieTimer > fadeAfterDeath) { if (SDL_GetTicks() - m_dieTimer > (fadeAfterDeath + 2000)) { m_entity->SetVisible(false); CLasagne::GetInstance()->DisableEntity(&m_entity); return; } m_entity->SetCurrentAnimation(const_cast<char*>("fade")); m_entity->SetFPS(10); } } TVector<float, 2> moveDirection; moveDirection.Set(132 - m_entity->GetPosition().x(), 96 - m_entity->GetPosition().y()); moveDirection.Normalize2D(); moveDirection.Scale(m_speed); if (m_health > 0) { const float alpha = static_cast<float>(132 - m_entity->GetPosition().x()) / static_cast<float>(96 - m_entity->GetPosition().y()); const float radAngle = atan(alpha); int rotation = static_cast<int>(radAngle * 57.0f); if (m_entity->GetPosition().y() > 96) rotation += 180; m_entity->SetRotation(rotation); } m_entity->SetPosition( (m_entity->GetPosition().x() + moveDirection.x()) - backGroundX, (m_entity->GetPosition().y() + moveDirection.y()) - backGroundY ); }