summaryrefslogtreecommitdiff
path: root/src/elements/plnt.c
diff options
context:
space:
mode:
authorjacksonmj <jacksonmj@jacksonmj.none>2011-01-07 16:18:22 (GMT)
committer jacksonmj <jacksonmj@jacksonmj.none>2011-01-07 16:18:22 (GMT)
commitf3ded5f08c0bbb3523a0ab2ee6e07538fabd79c2 (patch)
tree804bfff0e558daf780b4330db417e93e2ef695a2 /src/elements/plnt.c
parentb661418d7ecd44960f0e24eb7abd79cfc5eb5f0e (diff)
downloadpowder-f3ded5f08c0bbb3523a0ab2ee6e07538fabd79c2.zip
powder-f3ded5f08c0bbb3523a0ab2ee6e07538fabd79c2.tar.gz
More function pointers.
Diffstat (limited to 'src/elements/plnt.c')
-rw-r--r--src/elements/plnt.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/src/elements/plnt.c b/src/elements/plnt.c
new file mode 100644
index 0000000..695e1b8
--- /dev/null
+++ b/src/elements/plnt.c
@@ -0,0 +1,61 @@
+#include <powder.h>
+
+int update_PLNT(UPDATE_FUNC_ARGS) {
+ int r;
+ for (nx=-2; nx<3; nx++)
+ for (ny=-2; ny<3; 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 ((r&0xFF)==PT_WATR && 1>(rand()%250))
+ {
+ parts[i].type = PT_PLNT;
+ parts[r>>8].type = PT_PLNT;
+ parts[r>>8].life = 0;
+ }
+ else if ((r&0xFF)==PT_LAVA && 1>(rand()%250))
+ {
+ parts[i].life = 4;
+ parts[i].type = PT_FIRE;
+ }
+ else if ((r&0xFF)==PT_SMKE && (1>rand()%250))
+ {
+ parts[r>>8].type = PT_NONE;
+ parts[i].life = rand()%60 + 60;
+ }
+ else if ((r&0xFF)==PT_WOOD && (1>rand()%20) && abs(nx+ny)<=2 && VINE_MODE)
+ {
+ int nnx = rand()%3 -1;
+ int nny = rand()%3 -1;
+ if (x+nx+nnx>=0 && y+ny+nny>0 &&
+ x+nx+nnx<XRES && y+ny+nny<YRES && (nnx || nny))
+ {
+ if ((pmap[y+ny+nny][x+nx+nnx]>>8)>=NPART||pmap[y+ny+nny][x+nx+nnx])
+ continue;
+ if (create_part(-1,x+nx+nnx,y+ny+nny,PT_VINE))
+ parts[pmap[y+ny+nny][x+nx+nnx]>>8].temp = parts[i].temp;
+ }
+ }
+ //if(t==PT_SNOW && (r&0xFF)==PT_WATR && 15>(rand()%1000))
+ //t = parts[i].type = PT_WATR;
+ }
+ if (parts[i].life==2)
+ {
+ 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)
+ continue;
+ if (!r)
+ create_part(-1,x+nx,y+ny,PT_O2);
+ }
+ parts[i].life = 0;
+ }
+ return 0;
+}