Beispiel #1
0
/**
    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);
}
Beispiel #2
0
/**
    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);
}