diff options
| author | savask <savask@yandex.ru> | 2012-04-15 10:55:03 (GMT) |
|---|---|---|
| committer | savask <savask@yandex.ru> | 2012-04-15 10:56:55 (GMT) |
| commit | 8523da398fedef61dbf2f38f437d6c7361e61b86 (patch) | |
| tree | 85943b70d6933762f17c020ee3baa98fa3c144a0 /src/elements | |
| parent | 7a844f51ff7673aa49aee0f04517235c9a4da84a (diff) | |
| download | powder-8523da398fedef61dbf2f38f437d6c7361e61b86.zip powder-8523da398fedef61dbf2f38f437d6c7361e61b86.tar.gz | |
Added gel - a liquid with variable heat conductivity and viscosity.
Diffstat (limited to 'src/elements')
| -rw-r--r-- | src/elements/gel.c | 52 | ||||
| -rw-r--r-- | src/elements/newgraphics.c | 8 |
2 files changed, 60 insertions, 0 deletions
diff --git a/src/elements/gel.c b/src/elements/gel.c new file mode 100644 index 0000000..af10d7c --- /dev/null +++ b/src/elements/gel.c @@ -0,0 +1,52 @@ +#include <element.h> + +int update_GEL(UPDATE_FUNC_ARGS) { + int r, rx, ry; + 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; + + //Desaturation + if (((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW) + && parts[i].tmp<100) + { + parts[i].tmp = (100+parts[i].tmp)/2; + kill_part(r>>8); + } + + char gel = 0; + if ((r&0xFF)==PT_GEL) + gel = 1; + + //Concentration diffusion + if (gel && (parts[r>>8].tmp+1)<parts[i].tmp) + { + parts[r>>8].tmp++; + parts[i].tmp--; + } + + float dx, dy; + dx = parts[i].x - parts[r>>8].x; + dy = parts[i].y - parts[r>>8].y; + + //Stickness + if ((dx*dx + dy*dy)>1.5 && (gel || !ptypes[r&0xFF].falldown || (fabs(rx)<2 && fabs(ry)<2))) + { + float per, nd; + nd = dx*dx + dy*dy - 0.5; + + per = 5*(1 - parts[i].tmp/100)*(nd/(dx*dx + dy*dy + nd) - 0.5); + if (ptypes[r&0xFF].state==ST_LIQUID) + per *= 0.1; + + dx *= per; dy *= per; + parts[i].vx += dx; parts[r>>8].vx -= dx; + parts[i].vy += dy; parts[r>>8].vy -= dy; + } + } + return 0; +} diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c index af332fb..cf7b9a8 100644 --- a/src/elements/newgraphics.c +++ b/src/elements/newgraphics.c @@ -168,6 +168,14 @@ int graphics_WIFI(GRAPHICS_FUNC_ARGS) *pixel_mode |= EFFECT_LINES; return 0; } +int graphics_GEL(GRAPHICS_FUNC_ARGS) +{ + int q = cpart->tmp; + *colr = q*(32-255)/120+255; + *colg = q*(48-186)/120+186; + *colb = q*208/120; + return 0; +} int graphics_PRTI(GRAPHICS_FUNC_ARGS) { *firea = 8; |
