diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-29 15:34:53 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-29 15:34:53 (GMT) |
| commit | 26269ff052359af703c211e4d5d4a2447b45405b (patch) | |
| tree | 1ec5fbda113f3c285aeef1ab1b43cc63e733e699 /src/elements | |
| parent | 9c458b885112c28af8a3b7c7964e563692620c32 (diff) | |
| download | powder-26269ff052359af703c211e4d5d4a2447b45405b.zip powder-26269ff052359af703c211e4d5d4a2447b45405b.tar.gz | |
Added STOR, a block that can store a single particle and release when charged
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/pipe.c | 10 | ||||
| -rw-r--r-- | src/elements/stor.c | 43 |
2 files changed, 53 insertions, 0 deletions
diff --git a/src/elements/pipe.c b/src/elements/pipe.c index af008dc..9e060b5 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -152,6 +152,16 @@ int update_PIPE(UPDATE_FUNC_ARGS) { parts[i].pavg[1] = parts[r>>8].ctype; kill_part(r>>8); } + else if ((parts[i].tmp&0xFF) == 0 && (r&0xFF)==PT_STOR && parts[r>>8].tmp && (ptypes[parts[r>>8].tmp].falldown!= 0 || ptypes[parts[r>>8].tmp].state == ST_GAS)) + { + parts[i].tmp = parts[r>>8].tmp; + parts[i].temp = parts[r>>8].temp; + parts[i].flags = parts[r>>8].flags; + parts[i].pavg[0] = parts[r>>8].pavg[0]; + parts[i].pavg[1] = parts[r>>8].pavg[1]; + parts[r>>8].tmp = 0; + parts[r>>8].life = 0; + } } } } diff --git a/src/elements/stor.c b/src/elements/stor.c new file mode 100644 index 0000000..1f2558f --- /dev/null +++ b/src/elements/stor.c @@ -0,0 +1,43 @@ +#include <element.h> + +int update_STOR(UPDATE_FUNC_ARGS) { + int r, rx, ry, np, rx1, ry1; + if(parts[i].life && !parts[i].tmp) + parts[i].life--; + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if ((r>>8)>=NPART || !r) + continue; + if (!parts[i].tmp && !parts[i].life && (r&0xFF)!=PT_STOR && (r&0xFF)==parts[i].ctype && !(ptypes[(r&0xFF)].properties&TYPE_SOLID)) + { + parts[i].tmp = parts[r>>8].type; + parts[i].temp = parts[r>>8].temp; + parts[i].flags = parts[r>>8].life; + parts[i].pavg[0] = parts[r>>8].tmp; + parts[i].pavg[1] = parts[r>>8].ctype; + kill_part(r>>8); + } + if(parts[i].tmp && (r&0xFF)==PT_SPRK && parts[r>>8].ctype==PT_PSCN) + { + for(rx1 = 1; rx1 >= -1; rx1--){ + for(ry1 = 0; ry1 >= -1 && ry1 <= 1; ry1 = -ry1-ry1+1){ // Oscilate the Y starting at 0, 1, -1, 3, -5, etc (Though stop at -1) + np = create_part(-1,x+rx1,y+ry1,parts[i].tmp); + if (np!=-1) + { + parts[np].temp = parts[i].temp; + parts[np].life = parts[i].flags; + parts[np].tmp = parts[i].pavg[0]; + parts[np].ctype = parts[i].pavg[1]; + parts[i].tmp = 0; + parts[i].life = 10; + break; + } + } + } + } + } + return 0; +} |
