本文整理汇总了C++中Human::getX方法的典型用法代码示例。如果您正苦于以下问题:C++ Human::getX方法的具体用法?C++ Human::getX怎么用?C++ Human::getX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Human
的用法示例。
在下文中一共展示了Human::getX方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: doAI
virtual void doAI(list<Entity*> entities){
if(type == Type::Follower){
//try to follow the closest leader
Human *closest = 0;
double dToClosest = 0;
for(list<Entity*>::iterator it = entities.begin(); it != entities.end(); ++it){
Entity *e = *it;
if(e == this){
continue;
}
if(e->getType() == "human"){
Human *h = static_cast<Human*> (e);
if(h->getAItype() == Type::Leader){
double d = getDistance(e);
if(closest == 0 || dToClosest > d){
closest = h;
dToClosest = d;
}
}
}
}
if(closest && dToClosest){
ax = maxAcceleration*(closest->getX() - x)/dToClosest;
ay = maxAcceleration*(closest->getY() - y)/dToClosest;
}
}else{ //leader
if(scheduledChange < lifetime.getElapsedTime()){
scheduledChange = lifetime.getElapsedTime() + sf::seconds(rand()%5 + 1);
ax = rand()%((int) maxAcceleration) * (rand()%2 ? 1 : -1);
ay = rand()%((int) maxAcceleration) * (rand()%2 ? 1 : -1);
}
}
double mod = sqrt(pow(vx, 2) + pow(vy, 2)) ;
if(mod > maxSpeed){
vx *= maxSpeed/mod;
vy *= maxSpeed/mod;
}
}