The-Powder-Toy/src/elements/fog.c

23 lines
558 B
C
Raw Normal View History

#include <element.h>
2011-01-07 10:18:22 -06:00
int update_FOG(UPDATE_FUNC_ARGS) {
2011-01-10 08:41:03 -06:00
int r, rx, ry;
for (rx=-1; rx<2; rx++)
for (ry=-1; ry<2; ry++)
if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
2011-01-07 10:18:22 -06:00
{
2011-01-10 08:41:03 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 10:18:22 -06:00
if ((r>>8)>=NPART || !r)
continue;
if (ptypes[r&0xFF].state==ST_SOLID&&5>=rand()%50&&parts[i].life==0&&!((r&0xFF)==PT_CLNE||(r&0xFF)==PT_PCLN)) // TODO: should this also exclude BCLN?
2011-01-07 10:18:22 -06:00
{
2011-01-10 08:41:03 -06:00
part_change_type(i,x,y,PT_RIME);
2011-01-07 10:18:22 -06:00
}
2011-01-10 08:41:03 -06:00
if ((r&0xFF)==PT_SPRK)
2011-01-07 10:18:22 -06:00
{
parts[i].life += rand()%20;
}
}
return 0;
}