/** cherche à éviter une unité */ Vector Vehicule::evade(Vehicule& target) { Vector diff = target.getPosition() - m_position; float distance = diff.norme(); float anticipation_time=0; if(target.getVelocity().norme()>0) anticipation_time = distance / target.getVelocity().norme(); Vector futur_position = target.getPosition() + (target.getVelocity()*anticipation_time/2.f); return flee(futur_position); }
/** cherche à attrapper une unité */ Vector Vehicule::pursue(Vehicule& target, const float& offset) { Vector diff = target.getPosition() - m_position; float distance = diff.norme(); float anticipation_time=0; if(target.getVelocity().norme()>0) anticipation_time = distance / target.getVelocity().norme(); Vector futur_position = target.getPosition() + (target.getVelocity()*anticipation_time/2.f); return seek(futur_position, offset); }