State all parts?

  • firefreak11
    22nd Nov 2012 Member 0 Permalink

    How can I code something to react with any particle it touches?

    In the regular code, if I want element X to react with element Y to create element Z, I would code

    int update_X(UPDATE_FUNC_ARGS) {

    ...

    if (((r&0xFF)==PT_Y))

    {

    create_part(i,x,y,PT_Z);

    }


    But what would I code if I wanted it to react with all particles?

    please fill in the blank

    int update_X(UPDATE_FUNC_ARGS) {

    ...

    if (((r&0xFF)==PT_____))

    {

    create_part(i,x,y,PT_Z);

    }


    thanks, firefreak11

  • tommig
    22nd Nov 2012 Member 0 Permalink

    if parts[r>>8].type>0 && parts[r>>8].type<PT_NUM

    This might work, if I'm thinking right

  • firefreak11
    22nd Nov 2012 Member 0 Permalink

    @tommig (View Post)

     thanks i will give it a try

  • jacob1
    22nd Nov 2012 Developer 0 Permalink
    or, just
    if (r&0xFF)
    {
    ...
    }
  • boxmein
    22nd Nov 2012 Former Staff 0 Permalink
    @firefreak11 (View Post)

    if( (r&0xFF) ) {
    // do_stuff
    }
    else {
    // dont_do_stuff
    }

    Follows your code rules, if you will. :)
  • firefreak11
    22nd Nov 2012 Member 0 Permalink