diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-30 12:44:18 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-30 12:44:18 (GMT) |
| commit | d84abca852b9b693d40b253f674367789dda245c (patch) | |
| tree | 4c99fdeba5c849c215459b3402efbe9ef6a3ed8d /src/elements | |
| parent | a7ede2659ab354d36d9cf21bba040da884cc0357 (diff) | |
| download | powder-d84abca852b9b693d40b253f674367789dda245c.zip powder-d84abca852b9b693d40b253f674367789dda245c.tar.gz | |
Improvements to CBNW and BIZR act as a dye
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/bizr.c | 39 | ||||
| -rw-r--r-- | src/elements/cbnw.c | 23 |
2 files changed, 53 insertions, 9 deletions
diff --git a/src/elements/bizr.c b/src/elements/bizr.c new file mode 100644 index 0000000..d8a59cf --- /dev/null +++ b/src/elements/bizr.c @@ -0,0 +1,39 @@ +#include <element.h> + +//Used by ALL 3 BIZR states +int update_BIZR(UPDATE_FUNC_ARGS) { + int r, rx, ry, nr, ng, nb, na; + float tr, tg, tb, ta, mr, mg, mb, ma; + float blend; + if(parts[i].dcolour){ + 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) + continue; + if ((r&0xFF)!=PT_BIZR && (r&0xFF)!=PT_BIZRG && (r&0xFF)!=PT_BIZRS) + { + blend = 0.95f; + tr = (parts[r>>8].dcolour>>16)&0xFF; + tg = (parts[r>>8].dcolour>>8)&0xFF; + tb = (parts[r>>8].dcolour)&0xFF; + ta = (parts[r>>8].dcolour>>24)&0xFF; + + mr = (parts[i].dcolour>>16)&0xFF; + mg = (parts[i].dcolour>>8)&0xFF; + mb = (parts[i].dcolour)&0xFF; + ma = (parts[i].dcolour>>24)&0xFF; + + nr = (tr*blend) + (mr*(1-blend)); + ng = (tg*blend) + (mg*(1-blend)); + nb = (tb*blend) + (mb*(1-blend)); + na = (ta*blend) + (ma*(1-blend)); + + parts[r>>8].dcolour = nr<<16 | ng<<8 | nb | na<<24; + } + } + } + return 0; +} diff --git a/src/elements/cbnw.c b/src/elements/cbnw.c index 701f9ae..1834879 100644 --- a/src/elements/cbnw.c +++ b/src/elements/cbnw.c @@ -14,7 +14,7 @@ int update_CBNW(UPDATE_FUNC_ARGS) { if(oldt==1) { //Explode - if(!(rand()%2)) + if(rand()%4) { part_change_type(i,x,y,PT_WATR); } else { @@ -27,12 +27,22 @@ int update_CBNW(UPDATE_FUNC_ARGS) { 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) + if (!r) continue; - if ((r&0xFF)==PT_SALT && parts[i].tmp == 0 && 1>(rand()%250)) + if (ptypes[r&0xFF].properties&TYPE_PART && parts[i].tmp == 0 && 1>(rand()%250)) { //Start explode - parts[i].tmp = rand()%50;//(rand()%100)+50; + parts[i].tmp = rand()%25;//(rand()%100)+50; + } + else if(ptypes[r&0xFF].properties&TYPE_SOLID && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_GLAS && parts[i].tmp == 0 && (2-pv[y/CELL][x/CELL])>(rand()%20000)) + { + if(rand()%2) + { + part_change_type(i,x,y,PT_WATR); + } else { + pv[y/CELL][x/CELL] += 0.5f; + part_change_type(i,x,y,PT_CO2); + } } if ((r&0xFF)==PT_CBNW) { @@ -61,11 +71,6 @@ int update_CBNW(UPDATE_FUNC_ARGS) { return 1; } } - /*if ((r&0xFF)==PT_CNCT && 1>(rand()%500)) Concrete+Water to paste, not very popular - { - part_change_type(i,x,y,PT_PSTE); - kill_part(r>>8); - }*/ } return 0; } |
