Arc Element

  • cyberdragon
    2nd Aug 2013 Member 0 Permalink


    POST WILL BE CHANGED FOR NEW ISSUES:

    How can I get it to attract to the electrode? The lightning attract function does work a little at short distances but not further away.

     

    pNear = ARC_nearest_part(sim, i, parts[i].life*2.5);
    if (pNear!=-1)
    {
    int t=parts[pNear].type;
    float n_angle; // angle to nearest part
    float angle_diff;
    rx=parts[pNear].x-x;
    ry=parts[pNear].y-y;
    if (rx!=0 || ry!=0)
    n_angle = atan2f(-ry, rx);
    else
    n_angle = 0;
    if (n_angle<0)
    n_angle+=M_PI*2;
    angle_diff = fabsf(n_angle-parts[i].tmp*M_PI/180);
    if (angle_diff>M_PI)
    angle_diff = M_PI*2 - angle_diff;
    if (parts[i].life<5 || angle_diff<M_PI*0.8) // ARC strike
    {
    create_line_par(sim, x, y, x+rx, y+ry, PT_ARC, parts[i].temp, parts[i].life, parts[i].tmp-90, 0);

    if (t!=PT_TESC)
    {
    pNear=contact_part(sim, pNear, PT_ARC);
    if (pNear!=-1)
    {
    parts[pNear].tmp2=3;
    parts[pNear].life=(int)(1.0*parts[i].life/2-1);
    parts[pNear].tmp=parts[i].tmp-180;
    parts[pNear].temp=parts[i].temp;
    }
    }
    }
    else pNear=-1;
    }

    Edited 4 times by cyberdragon. Last: 2nd Aug 2013
  • MiningMarsh
    2nd Aug 2013 Member 0 Permalink

    Future note to anyone reading:

     

    please put your code in <code></code> tags.

  • cyberdragon
    2nd Aug 2013 Member 0 Permalink

    And have it cut in half becuase it's too big. -_-

  • boxmein
    2nd Aug 2013 Former Staff 0 Permalink

    @cyberdragon (View Post)
    It won't cut it in half ffs, it'll make it look readable.

  • cyberdragon
    2nd Aug 2013 Member 0 Permalink

    It cut in half, I tried repeatedly.

     

    Attracting should be easier for ARC because it doesn't fork and only goes to ARCE. So what if I have the ARCEs send their coordinants to a global series of arrays and have the arc compute the nearest one and move it's tip there. Also, I want to get rid of the cursor size control, do I have to have this linked to the attraction?