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

22 lines
461 B
C
Raw Normal View History

#include <element.h>
2011-01-07 10:18:22 -06:00
int update_VINE(UPDATE_FUNC_ARGS) {
2011-01-09 13:23:05 -06:00
int r, np, rx =(rand()%3)-1, ry=(rand()%3)-1;
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 13:23:05 -06:00
r = pmap[y+ry][x+rx];
2011-01-07 10:18:22 -06:00
if ((r>>8)>=NPART)
2011-01-09 13:23:05 -06:00
return 0;
2011-01-07 10:18:22 -06:00
if (1>rand()%15)
2011-01-09 13:23:05 -06:00
part_change_type(i,x,y,PT_PLNT);
2011-01-07 10:18:22 -06:00
else if (!r)
{
2011-01-09 13:23:05 -06:00
np = create_part(-1,x+rx,y+ry,PT_VINE);
if (np<0) return 0;
parts[np].temp = parts[i].temp;
part_change_type(i,x,y,PT_PLNT);
2011-01-07 10:18:22 -06:00
}
}
return 0;
}