diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-19 16:53:56 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-08-19 16:53:56 (GMT) |
| commit | ac4ffb8d5dbb2e3fe10a979e0cdc6c34a2a8a31f (patch) | |
| tree | 5d944a09c2a8e77919d3358ae3e987e19eb024f0 /src | |
| parent | a85121d767432b7754bf9a6dce04eca37be52f1a (diff) | |
| download | powder-ac4ffb8d5dbb2e3fe10a979e0cdc6c34a2a8a31f.zip powder-ac4ffb8d5dbb2e3fe10a979e0cdc6c34a2a8a31f.tar.gz | |
Fancy Coal effects
Diffstat (limited to 'src')
| -rw-r--r-- | src/elements/bcol.c | 34 | ||||
| -rw-r--r-- | src/elements/coal.c | 34 | ||||
| -rw-r--r-- | src/graphics.c | 63 |
3 files changed, 129 insertions, 2 deletions
diff --git a/src/elements/bcol.c b/src/elements/bcol.c index de394bc..bc8713c 100644 --- a/src/elements/bcol.c +++ b/src/elements/bcol.c @@ -1,7 +1,7 @@ #include <element.h> int update_BCOL(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, trade, temp; if (parts[i].life<=0) { create_part(i, x, y, PT_FIRE); return 1; @@ -32,5 +32,37 @@ int update_BCOL(UPDATE_FUNC_ARGS) { } } } + /*if(100-parts[i].life > parts[i].tmp2) + parts[i].tmp2 = 100-parts[i].life; + if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; + for ( trade = 0; trade<4; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + 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 (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion + { + int temp = parts[i].tmp2 - parts[r>>8].tmp2; + if(temp < 10) + continue; + if (temp ==1) + { + parts[r>>8].tmp2 ++; + parts[i].tmp2 --; + } + else if (temp>0) + { + parts[r>>8].tmp2 += temp/2; + parts[i].tmp2 -= temp/2; + } + } + } + }*/ + if(parts[i].temp > parts[i].tmp2) + parts[i].tmp2 = parts[i].temp; return 0; } diff --git a/src/elements/coal.c b/src/elements/coal.c index 424a1a1..e111890 100644 --- a/src/elements/coal.c +++ b/src/elements/coal.c @@ -1,7 +1,7 @@ #include <element.h> int update_COAL(UPDATE_FUNC_ARGS) { - int r, rx, ry; + int r, rx, ry, trade, temp; if (parts[i].life<=0) { create_part(i, x, y, PT_FIRE); return 1; @@ -39,5 +39,37 @@ int update_COAL(UPDATE_FUNC_ARGS) { } } } + /*if(100-parts[i].life > parts[i].tmp2) + parts[i].tmp2 = 100-parts[i].life; + if(parts[i].tmp2 < 0) parts[i].tmp2 = 0; + for ( trade = 0; trade<4; trade ++) + { + rx = rand()%5-2; + ry = rand()%5-2; + 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 (((r&0xFF)==PT_COAL || (r&0xFF)==PT_BCOL)&&(parts[i].tmp2>parts[r>>8].tmp2)&&parts[i].tmp2>0)//diffusion + { + int temp = parts[i].tmp2 - parts[r>>8].tmp2; + if(temp < 10) + continue; + if (temp ==1) + { + parts[r>>8].tmp2 ++; + parts[i].tmp2 --; + } + else if (temp>0) + { + parts[r>>8].tmp2 += temp/2; + parts[i].tmp2 -= temp/2; + } + } + } + }*/ + if(parts[i].temp > parts[i].tmp2) + parts[i].tmp2 = parts[i].temp; return 0; } diff --git a/src/graphics.c b/src/graphics.c index 233a178..696cab9 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -3470,6 +3470,69 @@ void draw_parts(pixel *vid) fire_b[y][x] = cb; } } + /*else if((t==PT_COAL || t==PT_BCOL) && parts[i].tmp2 > 100.0f-80.0f){ + float frequency = 3.1415/(2*100.0f-(100.0f-80.0f)); + int q = (parts[i].tmp2>100.0f)?100.0f-(100.0f-80.0f):parts[i].tmp2-(100.0f-80.0f); + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + + cr += parts[i].tmp2; + cg += parts[i].tmp2; + cb += parts[i].tmp2; + + + cr += sin(frequency*q) * 226; + cg += sin(frequency*q*4.55 +3.14) * 34; + cb += sin(frequency*q*2.22 +3.14) * 64; + + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + if (cr<=0) + cr = 0; + if (cg<=0) + cg = 0; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + }*/ + else if(t==PT_COAL || t==PT_BCOL){ + cr = PIXR(ptypes[t].pcolors); + cg = PIXG(ptypes[t].pcolors); + cb = PIXB(ptypes[t].pcolors); + + cr += (parts[i].tmp2-273.15f)/3; + cg += (parts[i].tmp2-273.15f)/3; + cb += (parts[i].tmp2-273.15f)/3; + + if((parts[i].temp-273.15f) > 300.0f-200.0f) + { + float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); + int q = ((parts[i].temp-273.15f)>300.0f)?300.0f-(300.0f-200.0f):(parts[i].temp-273.15f)-(300.0f-200.0f); + + cr += sin(frequency*q) * 226; + cg += sin(frequency*q*4.55 +3.14) * 34; + cb += sin(frequency*q*2.22 +3.14) * 64; + } + + if (cr>=255) + cr = 255; + if (cg>=255) + cg = 255; + if (cb>=255) + cb = 255; + if (cr<=0) + cr = 0; + if (cg<=0) + cg = 0; + if (cb<=0) + cb = 0; + blendpixel(vid, nx, ny, cr, cg, cb, 255); + } else //if no special effect, draw a simple pixel vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors; } |
