Energy particle question.

  • Videogamer555
    12th Feb 2012 Member 0 Permalink
    So if I wish to create an energy particle how would I do it using the PHOTONS array? Do I still use the pmap thing to initiate the new particle and then read its properties with photons? Or do I use the photons array to create the particle as well? Please show an example code, like how it's done with PHOT, NEUT, and ELEC.
  • jacksonmj
    12th Feb 2012 Developer 0 Permalink
    I'm not sure I understand the question. Normally, create_part is used to create particles, and doing so doesn't involve the photons array or pmap.

    Here's how PCLN creates PHOT:
    int np = create_part(-1, x+rx, y+ry, parts[i].ctype);
    if (np!=-1)
    {
    parts[np].vx = rx*3;
    parts[np].vy = ry*3;
    }
  • Videogamer555
    12th Feb 2012 Member 0 Permalink
    How are photons made to disappear the moment anything else is drawn on top of them? And how are photons created in such a state that they are susceptable to being "disappeared" the moment something is drawn on top of them, and not even leave a hole in the material that was drawn on top of them?

    For example, in the ELEC update function code there's this code here that includes the photons array. How does this work? Please explain what it's doing. Also what's the word "continue" mean in the code? Is this essential to making energy particles disappear when something is drawn over them?
    Also sorry but the code box doesn't really preserve all the code and messes some of it up.

    r = pmap[y+ry][x+rx];
    if (!r)
    r = photons[y+ry][x+rx];
    if (!r)
    continue;
    if ((r&0xFF)==PT_GLAS)
    {
    fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also shouldn't be here
    fire_g[y/CELL][x/CELL] += rand()%200;
    fire_b[y/CELL][x/CELL] += rand()%200;
    for (rrx=-1; rrx<=1; rrx++)<br/> {
    for (rry=-1; rry<=1; rry++)<br/> {
    if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx nb = create_part(-1, x+rx+rrx, y+ry+rry, PT_BOMB);
    if (nb!=-1) {
    parts[nb].tmp = 1;
    parts[nb].life = 50;
    parts[nb].temp = 400.0f;
    parts[nb].vx = rand()%20-10;
    parts[nb].vy = rand()%20-10;
    }
    }
    }
    }
    kill_part(i);
    return 1;
    }