From 8df470662fc687cedeac97fac2c4d8afe4ccedd0 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 29 Dec 2010 17:22:18 -0500 Subject: [PATCH] ARAY gets colored by FILT, woo --- src/graphics.c | 42 ++++++++++++++++++++++++++++++++++++++++-- src/main.c | 2 +- src/powder.c | 17 +++++++++++++---- 3 files changed, 54 insertions(+), 7 deletions(-) diff --git a/src/graphics.c b/src/graphics.c index a22cf5804..adc0c18d7 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) { diff --git a/src/main.c b/src/main.c index 8a0cf0e51..7acc85dce 100644 --- a/src/main.c +++ b/src/main.c @@ -67,7 +67,7 @@ static const char *it_msg = "\n\boUse 'Z' for a zoom tool. Click to make the drawable zoom window stay around. Use the wheel to change the zoom strength\n" "Use 'S' to save parts of the window as 'stamps'.\n" "'L' will load the most recent stamp, 'K' shows a library of stamps you saved.\n" - "'C' will cycle the display mode (Fire, Blob, Velocity and Pressure). The numbers 1 to 7 will do the same\n" + "'C' will cycle the display mode (Fire, Blob, Velocity, ect.). The numbers on the keyboard do the same\n" "Use the mouse scroll wheel to change the tool size for particles.\n" "The spacebar can be used to pause physics.\n" "'P' will take a screenshot and save it into the current directory.\n" diff --git a/src/powder.c b/src/powder.c index 8e7a4ea08..84d129bb5 100644 --- a/src/powder.c +++ b/src/powder.c @@ -1614,7 +1614,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) + if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) { h_count++; c_heat += parts[r>>8].temp; @@ -1632,7 +1632,7 @@ void update_particles_i(pixel *vid, int start, int inc) r = pmap[y+ny][x+nx]; if((r>>8)>=NPART || !r) continue; - if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) + if(parts[r>>8].type!=PT_NONE&&parts[i].type!=PT_NONE&&ptypes[parts[r>>8].type].hconduct>0&&!(parts[r>>8].type==PT_HSWC&&parts[r>>8].life!=10)&&!(parts[r>>8].type==PT_BRAY&&parts[i].type==PT_FILT)&&!(parts[i].type==PT_BRAY&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_PHOT&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZR&&parts[r>>8].type==PT_FILT)&&!(parts[i].type==PT_BIZRG&&parts[r>>8].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZR&&parts[i].type==PT_FILT)&&!(parts[r>>8].type==PT_BIZRG&&parts[i].type==PT_FILT)) { parts[r>>8].temp = parts[i].temp; } @@ -1984,6 +1984,7 @@ void update_particles_i(pixel *vid, int start, int inc) } } else if(t==PT_ARAY && parts[i].life==0){ + int colored =0; for(nx=-1; nx<2; nx++){ for(ny=-1; ny<2; ny++){ if(x+nx>=0 && y+ny>0 && x+nx>8)>=NPART)) { if(!r){ int nr = create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_BRAY); - if(nr!=-1&&destroy){ + if(nr!=-1){ + if(destroy){ parts[nr].tmp = 2; parts[nr].life = 2; + }else + parts[nr].ctype = colored; } } else if(!destroy) { if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==0){ @@ -2010,12 +2014,17 @@ void update_particles_i(pixel *vid, int start, int inc) parts[r>>8].type = PT_BRAY; parts[r>>8].life = 1020; parts[r>>8].tmp = 1; + if(!parts[r>>8].ctype) + parts[r>>8].ctype = colored; } docontinue = 0; } else if(parts[r>>8].type==PT_BRAY&&parts[r>>8].tmp==1){ parts[r>>8].life = 1020; //docontinue = 1; - } else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) { + } + else if(parts[r>>8].type==PT_FILT){ + colored = parts[r>>8].ctype; + }else if(parts[r>>8].type!=PT_INWR && parts[r>>8].type!=PT_ARAY) { if(nyy!=0 || nxx!=0){ create_part(-1, x+nxi+nxx, y+nyi+nyy, PT_SPRK); }