X and Y coordinates, particle count.

  • The-Con
    21st Mar 2011 Member 0 Permalink
    @dnerd
    I don't think so. When i need the X,Y coordinates, I do it the painful way. And to find how many there are, I also do it a semi-painful way.
  • HeyJD
    21st Mar 2011 Member 0 Permalink
    @dnerd
    There is a way:

    for(i=0; i<NPART; i++)
    {
    if(parts[i].type == TypeYouWantHere)
    {
    Thing you want to do here;
    }
    }


    So an example could be,:


    for(i=0; i<NPART; i++)
    {
    if(parts[i].type == PT_METL)
    {
    parts[i].life = 9999;
    }
    }


    That code would change all metl life to 9999.
  • dnerd
    21st Mar 2011 Member 0 Permalink
    @HeyJD
    so in the "thing you want to do here;"
    i could type "parts[i]. (here something in C which says to save the Y coordinates of those particles)"

    and it would do that?

    also, is there a command which sets a variable to the number of particles of a certain type?

    for example

    A=(this command:dust)

    sets a as the number of particles of dust?
  • Pilihp64
    21st Mar 2011 Developer 0 Permalink
    the location is automatically gotten for particles inside the update_particles_i function, it looks something like this

    for (i=0 ; i<NPART); i+=1)
    if (parts[i].type)
    {
    x = (int)(parts[i].x+0.5f);
    y = (int)(parts[i].y+0.5f);
    *stuff with coords x,y here*
    }

    the +0.5 is for rounding, then it is turned into an int for general usage (but it is still stored as float)
  • dnerd
    21st Mar 2011 Member 0 Permalink

    cracker64:

    inside the update_particles_i function


    so would that be inside some file?

    P.S. thanks everyone for helping a noob through the complexities of coding!
  • Pilihp64
    21st Mar 2011 Developer 0 Permalink
    yes that function is in powder.c, which has all the general reactions and properties of particles, specific element code is now in a separate *.c file.

    edit: yay 1000th post, i'm not noobish enough to create a topic for it like some OTHER people on this forum
  • dnerd
    21st Mar 2011 Member 0 Permalink
    @cracker64
    great, thanks alot, ill use this, but you can lock it since my question has been answered.