diff options
| author | Simon <simon@hardwired.org.uk> | 2010-12-29 22:24:29 (GMT) |
|---|---|---|
| committer | Simon <simon@hardwired.org.uk> | 2010-12-29 22:24:29 (GMT) |
| commit | c913fd55d395585e26ad91776d09e533ffb7b5aa (patch) | |
| tree | 1c1decb8a5e97b9f433c502c6ba9cd36326c5ffd /src/graphics.c | |
| parent | b2129bd129b0c3f92a0e7652f37c58853142b020 (diff) | |
| parent | 8df470662fc687cedeac97fac2c4d8afe4ccedd0 (diff) | |
| download | powder-c913fd55d395585e26ad91776d09e533ffb7b5aa.zip powder-c913fd55d395585e26ad91776d09e533ffb7b5aa.tar.gz | |
Merge branch 'master' of git://github.com/cracker64/The-Powder-Toy
Diffstat (limited to 'src/graphics.c')
| -rw-r--r-- | src/graphics.c | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/graphics.c b/src/graphics.c index 7095af8..6d6ebbf 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1915,12 +1915,50 @@ void draw_parts(pixel *vid) else if(t==PT_BRAY && parts[i].tmp==0) { int trans = parts[i].life * 7; - blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); + if(parts[i].ctype){ + cg = 0; + cb = 0; + cr = 0; + for(x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for(x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, trans); + }else + blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); } else if(t==PT_BRAY && parts[i].tmp==1) { int trans = parts[i].life/4; - blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); + if(parts[i].ctype){ + cg = 0; + cb = 0; + cr = 0; + for(x=0; x<12; x++) { + cr += (parts[i].ctype >> (x+18)) & 1; + cb += (parts[i].ctype >> x) & 1; + } + for(x=0; x<14; x++) + cg += (parts[i].ctype >> (x+9)) & 1; + x = 624/(cr+cg+cb+1); + cr *= x; + cg *= x; + cb *= x; + cr = cr>255?255:cr; + cg = cg>255?255:cg; + cb = cb>255?255:cb; + blendpixel(vid, nx, ny, cr, cg, cb, trans); + }else + blendpixel(vid, nx, ny, PIXR(ptypes[t].pcolors), PIXG(ptypes[t].pcolors), PIXB(ptypes[t].pcolors), trans); } else if(t==PT_BRAY && parts[i].tmp==2) { |
