herdem_dog.c
/**
 * Handler for when dog collides with sheep
 */
Handler for when dog collides with sheep
Handler for when dog collides with sheep
void herdem_dog_sheep_collision_handler(jty_c_info *c_info)
{
    jty_actor *dog = c_info->e1.actor;
    jty_actor *sheep = c_info->e2.actor;
    jty_vector v_rel = {sheep->vx - dog->vx, sheep->vy - dog->vy};
    sheep->x += c_info->normal.x * (c_info->penetration + 1);
    sheep->y += c_info->normal.y * (c_info->penetration + 1);
    dog->x -= c_info->normal.x * (c_info->penetration + 1);
    dog->y -= c_info->normal.y * (c_info->penetration + 1);
    if (c_info->normal.x) {
        dog->vx += 2 * v_rel.x;
    } else {
        dog->vy += 2 * v_rel.y;
    }
}
void herdem_dog_sheep_collision_handler ( jty_c_info * c_info ) { jty_actor * dog = c_info -> e1 . actor ; jty_actor * sheep = c_info -> e2 . actor ; jty_vector v_rel = { sheep -> vx - dog -> vx , sheep -> vy - dog -> vy } ; sheep -> x += c_info -> normal . x * ( c_info -> penetration + 1 ) ; sheep -> y += c_info -> normal . y * ( c_info -> penetration + 1 ) ; dog -> x -= c_info -> normal . x * ( c_info -> penetration + 1 ) ; dog -> y -= c_info -> normal . y * ( c_info -> penetration + 1 ) ; if ( c_info -> normal . x ) { dog -> vx += 2 * v_rel . x ; } else { dog -> vy += 2 * v_rel . y ; } }
Handler for when dog collides with sheep
Handler for when dog collides with sheep