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

27 lines
572 B
C
Raw Normal View History

#include <element.h>
2011-01-07 10:18:22 -06:00
int update_RIME(UPDATE_FUNC_ARGS) {
2011-01-09 18:46:34 -06:00
int r, rx, ry;
2011-01-07 10:18:22 -06:00
parts[i].vx = 0;
parts[i].vy = 0;
2011-01-09 18:46:34 -06:00
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-09 18:46:34 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 10:18:22 -06:00
if ((r>>8)>=NPART || !r)
continue;
2011-01-09 18:46:34 -06:00
if ((r&0xFF)==PT_SPRK)
2011-01-07 10:18:22 -06:00
{
2011-01-09 18:46:34 -06:00
part_change_type(i,x,y,PT_FOG);
2011-01-07 10:18:22 -06:00
parts[i].life = rand()%50 + 60;
}
2011-01-09 18:46:34 -06:00
else if ((r&0xFF)==PT_FOG&&parts[r>>8].life>0)
2011-01-07 10:18:22 -06:00
{
2011-01-09 18:46:34 -06:00
part_change_type(i,x,y,PT_FOG);
2011-01-07 10:18:22 -06:00
parts[i].life = parts[r>>8].life;
}
}
return 0;
}