summaryrefslogtreecommitdiff
path: root/src/elements/fwrk.c
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-10 14:41:03 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-10 14:41:03 (GMT)
commit54f9f872b9e4d5a0086d6de104e84d43b125c349 (patch)
treeb567fb9d3710acbce22f8193bfe2585bb2988bed /src/elements/fwrk.c
parent855281295fbc23366e8b84d7c8e55816d6f47a87 (diff)
downloadpowder-54f9f872b9e4d5a0086d6de104e84d43b125c349.zip
powder-54f9f872b9e4d5a0086d6de104e84d43b125c349.tar.gz
Finish update function cleanup
Diffstat (limited to 'src/elements/fwrk.c')
-rw-r--r--src/elements/fwrk.c34
1 files changed, 15 insertions, 19 deletions
diff --git a/src/elements/fwrk.c b/src/elements/fwrk.c
index 30b5e0b..f74990d 100644
--- a/src/elements/fwrk.c
+++ b/src/elements/fwrk.c
@@ -1,42 +1,37 @@
#include <powder.h>
int update_FWRK(UPDATE_FUNC_ARGS) {
- int r;
+ int r, rx, ry, np;
if ((parts[i].temp>400&&(9+parts[i].temp/40)>rand()%100000&&parts[i].life==0&&!pmap[y-1][x])||parts[i].ctype==PT_DUST)
{
- create_part(-1, x , y-1 , PT_FWRK);
- r = pmap[y-1][x];
- if ((r&0xFF)==PT_FWRK)
+ np = create_part(-1, x , y-1 , PT_FWRK);
+ if (np!=-1)
{
parts[r>>8].vy = rand()%8-22;
parts[r>>8].vx = rand()%20-rand()%20;
parts[r>>8].life=rand()%15+25;
- parts[i].type=PT_NONE;
+ kill_part(i);
+ return 1;
}
}
- if (parts[i].life>1)
- {
- if (parts[i].life>=45&&parts[i].type==PT_FWRK)
- parts[i].life=0;
- }
+ if (parts[i].life>=45)
+ parts[i].life=0;
if ((parts[i].life<3&&parts[i].life>0)||parts[i].vy>6&&parts[i].life>0)
{
int q = (rand()%255+1);
int w = (rand()%255+1);
int e = (rand()%255+1);
- for (nx=-1; nx<2; nx++)
- for (ny=-2; ny<3; ny++)
- if (x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES)
+ for (rx=-1; rx<2; rx++)
+ for (ry=-2; ry<3; ry++)
+ if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
{
if (5>=rand()%8)
{
- if (!pmap[y+ny][x+nx])
+ if (!pmap[y+ry][x+rx])
{
- create_part(-1, x+nx, y+ny , PT_DUST);
+ np = create_part(-1, x+rx, y+ry , PT_DUST);
pv[y/CELL][x/CELL] += 2.00f*CFDS;
- r = pmap[y+ny][x+nx];
- if (parts[r>>8].type==PT_DUST)
+ if (np!=-1)
{
parts[r>>8].vy = -(rand()%10-1);
parts[r>>8].vx = ((rand()%2)*2-1)*rand()%(5+5)+(parts[i].vx)*2 ;
@@ -49,7 +44,8 @@ int update_FWRK(UPDATE_FUNC_ARGS) {
}
}
}
- parts[i].type=PT_NONE;
+ kill_part(i);
+ return 1;
}
return 0;
}