本文整理汇总了C++中TVector::Normalize2D方法的典型用法代码示例。如果您正苦于以下问题:C++ TVector::Normalize2D方法的具体用法?C++ TVector::Normalize2D怎么用?C++ TVector::Normalize2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TVector
的用法示例。
在下文中一共展示了TVector::Normalize2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Update
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
);
}
开发者ID:SamOatesUniversity,项目名称:Year-3---Device-Programming---Memory-Manager---Horde,代码行数:55,代码来源:enemyzombie.cpp