Easier fancy effects, by Mur

This commit is contained in:
Simon 2011-01-04 19:42:50 +00:00
parent 43065ba94c
commit 0eb4089b08
2 changed files with 164 additions and 198 deletions

View File

@ -217,6 +217,7 @@
#define PROP_DEADLY 0x0400 //1024 Is deadly for stickman.
#define PROP_HOT_GLOW 0x0800 //2048 Hot Metal Glow
#define PROP_LIFE 0x1000 //4096 Is a GoL type
#define PROP_RADIOACTIVE 0x2000 //8192 Radioactive
#define FLAG_STAGNANT 1
struct particle
@ -303,7 +304,7 @@ static const part_type ptypes[PT_NUM] =
{"SNOW", PIXPACK(0xC0E0FF), 0.7f, 0.01f * CFDS, 0.96f, 0.90f, -0.1f, 0.05f, 0.01f, -0.00005f* CFDS,1, 0, 0, 0, 20, 1, 50, SC_POWDERS, R_TEMP-30.0f+273.15f, 46, "Light particles.", TYPE_PART, NULL},
{"WOOD", PIXPACK(0xC0A040), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 15, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 164, "Solid. Flammable.", TYPE_SOLID, NULL},
{"NEUT", PIXPACK(0x20E0FF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.01f, 0.002f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 60, "Neutrons. Interact with matter in odd ways.", TYPE_ENERGY, NULL},
{"PLUT", PIXPACK(0x407020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 251, "Heavy particles. Fissile. Generates neutrons under pressure.", TYPE_PART|PROP_NEUTPENETRATE, NULL},
{"PLUT", PIXPACK(0x407020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+4.0f +273.15f, 251, "Heavy particles. Fissile. Generates neutrons under pressure.", TYPE_PART|PROP_NEUTPENETRATE|PROP_RADIOACTIVE, NULL},
{"PLNT", PIXPACK(0x0CAC00), 0.0f, 0.00f * CFDS, 0.95f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 20, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 65, "Plant, drinks water and grows.", TYPE_SOLID, NULL},
{"ACID", PIXPACK(0xED55FF), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 2, 40, 0, 0, 1, 1, 10, SC_LIQUID, R_TEMP+0.0f +273.15f, 34, "Dissolves almost everything.", TYPE_LIQUID, NULL},
{"VOID", PIXPACK(0x790B0B), 0.0f, 0.00f * CFDS, 1.00f, 0.00f, 0.0f, 0.0f, 0.00f, -0.0003f* CFDS, 0, 0, 0, 0, 0, 1, 100, SC_SPECIAL, R_TEMP+0.0f +273.15f, 251, "Hole, will drain away any particles.", TYPE_SOLID, NULL},
@ -316,7 +317,7 @@ static const part_type ptypes[PT_NUM] =
{"BMTL", PIXPACK(0x505070), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Breakable metal.", TYPE_SOLID|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
{"BRMT", PIXPACK(0x705060), 0.4f, 0.04f * CFDS, 0.94f, 0.95f, -0.1f, 0.3f, 0.00f, 0.000f * CFDS, 1, 0, 0, 2, 2, 1, 90, SC_POWDERS, R_TEMP+0.0f +273.15f, 211, "Broken metal.", TYPE_PART|PROP_CONDUCTS|PROP_HOT_GLOW, NULL},
{"PHOT", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 1.00f, 1.00f, -0.99f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 0, 1, -1, SC_ELEC, R_TEMP+900.0f+273.15f, 251, "Photons. Travel in straight lines.", TYPE_ENERGY, NULL},
{"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", TYPE_PART, NULL},
{"URAN", PIXPACK(0x707020), 0.4f, 0.01f * CFDS, 0.99f, 0.95f, 0.0f, 0.4f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 0, 1, 90, SC_NUCLEAR, R_TEMP+30.0f+273.15f, 251, "Heavy particles. Generates heat under pressure.", TYPE_PART | PROP_RADIOACTIVE, NULL},
{"WAX", PIXPACK(0xF0F0BB), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 10, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 44, "Wax. Melts at moderately high temperatures.", TYPE_SOLID, NULL},
{"MWAX", PIXPACK(0xE0E0AA), 0.3f, 0.02f * CFDS, 0.95f, 0.80f, 0.0f, 0.15f, 0.00f, 0.000001f* CFDS,2, 5, 0, 0, 2, 1, 25, SC_LIQUID, R_TEMP+28.0f+273.15f, 44, "Liquid Wax.", TYPE_LIQUID, NULL},
{"PSCN", PIXPACK(0x805050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "P-Type Silicon, Will transfer current to any conductor.", TYPE_SOLID, NULL},

View File

@ -1478,6 +1478,163 @@ void draw_parts(pixel *vid)
cb = 0;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
else if(cmode==CM_FANCY)
{
if(ptypes[parts[i].type].properties&TYPE_LIQUID)
{
if(parts[i].type==PT_DEUT)
{
cr = PIXR(ptypes[t].pcolors) + parts[i].life*1;
cg = PIXG(ptypes[t].pcolors) + parts[i].life*2;
cb = PIXB(ptypes[t].pcolors) + parts[i].life*4;
if(cr>=255)
cr = 255;
if(cg>=255)
cg = 255;
if(cb>=255)
cb = 255;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,50);
}
}
}
else if(parts[i].type==PT_LAVA && parts[i].life)
{
cr = parts[i].life * 2 + 0xE0;
cg = parts[i].life * 1 + 0x50;
cb = parts[i].life/2 + 0x10;
if(cr>255) cr = 255;
if(cg>192) cg = 192;
if(cb>128) cb = 128;
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,50);
}
}
}
else if(parts[i].type==PT_GLOW)
{
fg = 0;
fb = 0;
fr = 0;
if(pv[ny/CELL][nx/CELL]>0) {
fg = 6 * pv[ny/CELL][nx/CELL];
fb = 4 * pv[ny/CELL][nx/CELL];
fr = 2 * pv[ny/CELL][nx/CELL];
}
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(0x44 + fr*8, 0, 255), (int)restrict_flt(0x88 + fg*8, 0, 255), (int)restrict_flt(0x44 + fb*8, 0, 255));
/*x = nx/CELL;
y = ny/CELL;
fg += fire_g[y][x];
if(fg > 255) fg = 255;
fire_g[y][x] = fg;
fb += fire_b[y][x];
if(fb > 255) fb = 255;
fire_b[y][x] = fb;
fr += fire_r[y][x];
if(fr > 255) fr = 255;
fire_r[y][x] = fr;*/
cr = (int)restrict_flt(0x44 + fr*8, 0, 255);
cg = (int)restrict_flt(0x88 + fg*8, 0, 255);
cb = (int)restrict_flt(0x44 + fb*8, 0, 255);
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,50);
}
}
}
else
{
cr = PIXR(ptypes[t].pcolors);
cg = PIXG(ptypes[t].pcolors);
cb = PIXB(ptypes[t].pcolors);
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,50);
}
}
}
}
else if (ptypes[parts[i].type].properties&TYPE_GAS)
{
//if(parts[i].type!=PT_FIRE&&parts[i].type!=PT_SMKE&&parts[i].type!=PT_PLSM&&parts[i].type!=PT_WTRV)
{
cr = PIXR(ptypes[t].pcolors);
cg = PIXG(ptypes[t].pcolors);
cb = PIXB(ptypes[t].pcolors);
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,180);
else if (abs(y) != 0 && abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,50);
else
blendpixel(vid,x+nx,y+ny,cr,cg,cb,80);
}
}
}
}
else if(ptypes[parts[i].type].properties&PROP_RADIOACTIVE)
{
int tempx = 0;
int tempy = 0;
cr = PIXR(ptypes[t].pcolors);
cg = PIXG(ptypes[t].pcolors);
cb = PIXB(ptypes[t].pcolors);
//blendpixel(vid, nx, ny, cr, cg, cb, 192);
//blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
//blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
//blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
//blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
addpixel(vid, nx, ny, cr, cg, cb, 192);
addpixel(vid, nx+1, ny, cr, cg, cb, 96);
addpixel(vid, nx-1, ny, cr, cg, cb, 96);
addpixel(vid, nx, ny+1, cr, cg, cb, 96);
addpixel(vid, nx, ny-1, cr, cg, cb, 96);
for(tempx = 2; tempx < 7; tempx++) {
for(tempy = 2; tempy < 7; tempy++) {
addpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
addpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
addpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
addpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
//blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
//blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
//blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
//blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
}
else
{
vid[ny*(XRES+BARSIZE)+nx] = ptypes[t].pcolors;
}
}
else if(cmode==CM_LIFE)
{
float frequency = 0.4;
@ -1503,22 +1660,6 @@ void draw_parts(pixel *vid)
cb = 0;
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
else if(t==PT_MWAX&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,224,224,170,255);
else if (abs(y) != 0 && abs(x) != 0)
blendpixel(vid,x+nx,y+ny,224,224,170,20);
else
blendpixel(vid,x+nx,y+ny,224,224,170,40);
}
}
}
else if(t==PT_QRTZ || t==PT_PQRT)
{
int z = parts[i].tmp;
@ -1788,7 +1929,9 @@ void draw_parts(pixel *vid)
}
else if(t==PT_INVIS && (pv[ny/CELL][nx/CELL]>4.0f ||pv[ny/CELL][nx/CELL]<-4.0f))
{
blendpixel(vid, nx, ny, 15, 0, 150, 100);
}
else if(t==PT_ACID)
{
if(parts[i].life>255) parts[i].life = 255;
@ -1798,20 +1941,7 @@ void draw_parts(pixel *vid)
cr = PIXR(ptypes[t].pcolors)/s;
cg = PIXG(ptypes[t].pcolors)/s;
cb = PIXB(ptypes[t].pcolors)/s;
if(cmode==CM_FANCY) {
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,cr,cg,cb,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,cr,cg,cb,40);
}
}
} else {
blendpixel(vid, nx, ny, cr, cg, cb, 255);
}
blendpixel(vid, nx, ny, cr, cg, cb, 255);
if(cmode==CM_BLOB)
{
@ -1826,19 +1956,6 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny+1, cr, cg, cb, 112);
}
}
else if(t==PT_OIL&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,64,64,16,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,64,64,16,40);
}
}
}
else if(t==PT_NEUT)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
@ -1870,59 +1987,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx+1, ny+1, cr, cg, cb, 32);
blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32);
}
} else if(t==PT_PLUT&&cmode == CM_FANCY)
{
int tempx;
int tempy;
cr = 0x40;
cg = 0x70;
cb = 0x20;
blendpixel(vid, nx, ny, cr, cg, cb, 192);
blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
for(tempx = 2; tempx < 10; tempx++) {
for(tempy = 2; tempy < 10; tempy++) {
blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
} else if(t==PT_URAN&&cmode == CM_FANCY)
{
int tempx;
int tempy;
cr = 0x70;
cg = 0x70;
cb = 0x20;
blendpixel(vid, nx, ny, cr, cg, cb, 192);
blendpixel(vid, nx+1, ny, cr, cg, cb, 96);
blendpixel(vid, nx-1, ny, cr, cg, cb, 96);
blendpixel(vid, nx, ny+1, cr, cg, cb, 96);
blendpixel(vid, nx, ny-1, cr, cg, cb, 96);
for(tempx = 2; tempx < 10; tempx++) {
for(tempy = 2; tempy < 10; tempy++) {
blendpixel(vid, nx+tempx, ny-tempy, cr, cg, cb, 5);
blendpixel(vid, nx-tempx, ny+tempy, cr, cg, cb, 5);
blendpixel(vid, nx+tempx, ny+tempy, cr, cg, cb, 5);
blendpixel(vid, nx-tempx, ny-tempy, cr, cg, cb, 5);
}
}
} else if(t==PT_SLTW&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,64,80,240,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,64,80,240,50);
}
}
}
}
else if(t==PT_FILT)
{
int temp_bin = (int)((parts[i].temp-273.0f)*0.025f);
@ -2069,19 +2134,6 @@ void draw_parts(pixel *vid)
y = ny;
blendpixel(vid,x,y,17,217,24,255);
}
else if(t==PT_LNTG&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,128,160,223,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,128,160,223,50);
}
}
}
else if(t==PT_SMKE)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
@ -2117,93 +2169,6 @@ void draw_parts(pixel *vid)
}
}
}
else if(t==PT_WATR&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,32,48,208,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,32,48,208,50);
}
}
} else if(t==PT_DSTW&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,32,48,208,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,32,48,208,50);
}
}
}
else if(t==PT_NITR&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,32,224,16,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,32,224,16,50);
}
}
}
else if(t==PT_LRBD&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,170,170,170,100);
else if (abs(y) != 0 || abs(x) != 0)
blendpixel(vid,x+nx,y+ny,170,170,170,50);
}
}
}
else if(t==PT_NBLE&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,235,73,23,100);
else if (abs(y) != 0 && abs(x) != 0)
blendpixel(vid,x+nx,y+ny,235,73,23,30);
else
blendpixel(vid,x+nx,y+ny,235,73,23,50);
}
}
}
else if(t==PT_GAS&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
{
for(y=-1; y<=1; y++)
{
if ((abs(x) == 0) && (abs(y) == 0))
blendpixel(vid,x+nx,y+ny,255,255,0,180);
else if (abs(y) != 0 && abs(x) != 0)
blendpixel(vid,x+nx,y+ny,255,255,0,50);
else
blendpixel(vid,x+nx,y+ny,255,255,0,80);
}
}
}
else if(t==PT_WTRV)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)