summaryrefslogtreecommitdiff
path: root/src/elements/sing.c
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-07 20:03:58 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-07 20:03:58 (GMT)
commitb69712bbdbaf32fef65e15141458cb27f9f7ec88 (patch)
tree622d2d413fe4edbe683c729d500206c447624b8d /src/elements/sing.c
parentfa1868314c1d48de9000c45dc8bcde36d92472cb (diff)
downloadpowder-b69712bbdbaf32fef65e15141458cb27f9f7ec88.zip
powder-b69712bbdbaf32fef65e15141458cb27f9f7ec88.tar.gz
Some more function pointers
Diffstat (limited to 'src/elements/sing.c')
-rw-r--r--src/elements/sing.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/elements/sing.c b/src/elements/sing.c
new file mode 100644
index 0000000..8f7c0a7
--- /dev/null
+++ b/src/elements/sing.c
@@ -0,0 +1,59 @@
+#include <powder.h>
+
+int update_SING(UPDATE_FUNC_ARGS) {
+ int r;
+ int singularity = -parts[i].life;
+
+ if (pv[y/CELL][x/CELL]<singularity)
+ pv[y/CELL][x/CELL] += 0.1f*(singularity-pv[y/CELL][x/CELL]);
+ if (y+CELL<YRES && pv[y/CELL+1][x/CELL]<singularity)
+ pv[y/CELL+1][x/CELL] += 0.1f*(singularity-pv[y/CELL+1][x/CELL]);
+ if (x+CELL<XRES)
+ {
+ pv[y/CELL][x/CELL+1] += 0.1f*(singularity-pv[y/CELL][x/CELL+1]);
+ if (y+CELL<YRES)
+ pv[y/CELL+1][x/CELL+1] += 0.1f*(singularity-pv[y/CELL+1][x/CELL+1]);
+ }
+ if (y+CELL>0 && pv[y/CELL-1][x/CELL]<singularity)
+ pv[y/CELL-1][x/CELL] += 0.1f*(singularity-pv[y/CELL-1][x/CELL]);
+ if (x+CELL>0)
+ {
+ pv[y/CELL][x/CELL-1] += 0.1f*(singularity-pv[y/CELL][x/CELL-1]);
+ 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))
+ {
+ r = pmap[y+ny][x+nx];
+ if ((r>>8)>=NPART || !r)
+ continue;
+ if (parts[r>>8].type!=PT_DMND&&33>=rand()/(RAND_MAX/100)+1)
+ {
+ if (parts[r>>8].type==PT_SING && parts[r>>8].life >10)
+ {
+ if (parts[i].life+parts[r>>8].life > 255)
+ continue;
+ parts[i].life += parts[r>>8].life;
+ }
+ else
+ {
+ if (parts[i].life+3 > 255)
+ {
+ if (parts[r>>8].type!=PT_SING && 1>rand()%100)
+ {
+ parts[r>>8].type = PT_SING;
+ parts[r>>8].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;
+ }
+ }
+ return 0;
+}