summaryrefslogtreecommitdiff
path: root/src/elements/sing.c
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-10 00:46:34 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-10 00:46:34 (GMT)
commit855281295fbc23366e8b84d7c8e55816d6f47a87 (patch)
tree761d7cbaf37e3f10b1ee97f72d34f1da70d6732d /src/elements/sing.c
parent88d107f18a9c6d37493a953142a503d963ec37b1 (diff)
downloadpowder-855281295fbc23366e8b84d7c8e55816d6f47a87.zip
powder-855281295fbc23366e8b84d7c8e55816d6f47a87.tar.gz
More update functions cleanup.
Diffstat (limited to 'src/elements/sing.c')
-rw-r--r--src/elements/sing.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/elements/sing.c b/src/elements/sing.c
index 8f7c0a7..7127f77 100644
--- a/src/elements/sing.c
+++ b/src/elements/sing.c
@@ -1,7 +1,7 @@
#include <powder.h>
int update_SING(UPDATE_FUNC_ARGS) {
- int r;
+ int r, rx, ry;
int singularity = -parts[i].life;
if (pv[y/CELL][x/CELL]<singularity)
@@ -22,17 +22,16 @@ int update_SING(UPDATE_FUNC_ARGS) {
if (y+CELL>0)
pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
}
- for (nx=-1; nx<2; nx++)
- for (ny=-1; ny<2; ny++)
- if (x+nx>=0 && y+ny>0 &&
- x+nx<XRES && y+ny<YRES && (nx || ny))
+ 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))
{
- r = pmap[y+ny][x+nx];
+ r = pmap[y+ry][x+rx];
if ((r>>8)>=NPART || !r)
continue;
- if (parts[r>>8].type!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1)
+ if ((r&0xFF)!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1)
{
- if (parts[r>>8].type==PT_SING && parts[r>>8].life >10)
+ if ((r&0xFF)==PT_SING && parts[r>>8].life >10)
{
if (parts[i].life+parts[r>>8].life > 255)
continue;
@@ -44,15 +43,16 @@ int update_SING(UPDATE_FUNC_ARGS) {
{
if (parts[r>>8].type!=PT_SING && 1>rand()%100)
{
- parts[r>>8].type = PT_SING;
- parts[r>>8].life = rand()%50+60;
+ int np;
+ np = create_part(r>>8,x+rx,y+ry,PT_SING);
+ parts[np].life = rand()%50+60;
}
continue;
}
parts[i].life += 3;
}
parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP);
- parts[r>>8].type=PT_NONE;
+ kill_part(r>>8);
}
}
return 0;