本文整理汇总了C++中GameObject::GetNext方法的典型用法代码示例。如果您正苦于以下问题:C++ GameObject::GetNext方法的具体用法?C++ GameObject::GetNext怎么用?C++ GameObject::GetNext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GameObject
的用法示例。
在下文中一共展示了GameObject::GetNext方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: AvoidWalls
void Boid::AvoidWalls()
{
for (GameObject* obj = GameObject::All(); obj != NULL; obj = obj->GetNext())
{
// do strong separation for walls
if (obj->GetType() == GameObject::TWall)
{
Vec2 delta = GetPosition() - obj->GetPosition();
float dist = delta.Length();
if (dist < 2.f && dist > 0.f)
AddForce(Steer(delta.Normalize() / dist));
}
}
// avoid outer walls
Vec2 steer;
if (GetPosition().x < 1.f)
steer += Steer(Vec2(1.f, 0.f));
if (GetPosition().x > 19.f)
steer += Steer(Vec2(-1.f, 0.f));
if (GetPosition().y < 1.f)
steer += Steer(Vec2(0.f, 1.f));
if (GetPosition().y > 14.f)
steer += Steer(Vec2(0.f, -1.f));
AddForce(2.f * steer);
}
示例2: FindClosest
void Boid::FindClosest(BoidFriend* boids, int& count, int maxCount)
{
count = 0;
for (GameObject* obj = GameObject::All(); obj != NULL; obj = obj->GetNext())
{
if (obj != this)
{
Vec2 delta = GetPosition() - obj->GetPosition();
float dist = delta.Length();
// average position and direction for boids close enough to matter
if (dist < 2.25f)
InsertClosest((Boid*)obj, dist, boids, count, maxCount);
}
}
}