diff --git a/build/test.frag b/build/test.frag deleted file mode 100644 index 0b7a0a8f5..000000000 --- a/build/test.frag +++ /dev/null @@ -1,5 +0,0 @@ -uniform sampler2D fireAlpha; -void main () { - vec4 texColor = texture2D(fireAlpha, gl_PointCoord); - gl_FragColor = vec4(gl_Color.rgb, texColor.a*gl_Color.a); -} diff --git a/build/test.lua b/build/test.lua deleted file mode 100644 index a41bdd772..000000000 --- a/build/test.lua +++ /dev/null @@ -1,18 +0,0 @@ -tpt.register_step("do_step") -numberthing = 0 -increment = 2 -function do_step() - numberthing = numberthing + increment; - if numberthing >= 400 then - increment = -2 - elseif numberthing < 4 then - increment = 2 - end - tpt.drawtext(numberthing, 50, "Oh my god, this is amazing", 255, 255, 255, 255) - tpt.drawtext(mousex, mousey, "Oh my god, this is amazing", 255, 255, 255, 255) - tpt.reset_velocity(10, 10, 20, 20) - tpt.reset_gravity_field(10, 10, 20, 20) - tpt.set_pressure(10, 10, 20, 20) - tpt.set_gravity(75, 45, 1, 1, 8) - return false -end diff --git a/build/test.vert b/build/test.vert deleted file mode 100644 index 83fc56f69..000000000 --- a/build/test.vert +++ /dev/null @@ -1,5 +0,0 @@ -void main(void) -{ - gl_Position = ftransform();; - gl_FrontColor = gl_Color; -} diff --git a/includes/graphics.h b/includes/graphics.h index 962a04ee6..bbc0ea80c 100644 --- a/includes/graphics.h +++ b/includes/graphics.h @@ -61,6 +61,21 @@ extern unsigned int fire_alpha[CELL*3][CELL*3]; extern pixel *fire_bg; extern pixel *pers_bg; +struct gcache_item +{ + int isready; + int pixel_mode; + int colr, colg, colb; + int firea, firer, fireg, fireb; +}; +typedef struct gcache_item gcache_item; + +gcache_item *graphicscache; + +int graphics_DEFAULT(GRAPHICS_FUNC_ARGS); + +void prepare_graphicscache(); + void draw_rgba_image(pixel *vid, unsigned char *data, int x, int y, float a); void *ptif_pack(pixel *src, int w, int h, int *result_size); diff --git a/includes/powder.h b/includes/powder.h index bf8c5d563..a490fe1cd 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -245,7 +245,23 @@ #define FLAG_STAGNANT 1 -#define GRAPHICS_FUNC_ARGS int i, int nx, int ny, int *pixel_mode, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb +#define GRAPHICS_FUNC_ARGS particle *cpart, int nx, int ny, int *pixel_mode, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb +#define GRAPHICS_FUNC_SUBCALL_ARGS cpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb + + +struct particle +{ + int type; + int life, ctype; + float x, y, vx, vy; + float temp; + float pavg[2]; + int flags; + int tmp; + int tmp2; + unsigned int dcolour; +}; +typedef struct particle particle; int graphics_FIRE(GRAPHICS_FUNC_ARGS); int graphics_SMKE(GRAPHICS_FUNC_ARGS); @@ -288,6 +304,8 @@ int graphics_FIRW(GRAPHICS_FUNC_ARGS); int graphics_BOMB(GRAPHICS_FUNC_ARGS); int graphics_GBMB(GRAPHICS_FUNC_ARGS); int graphics_COAL(GRAPHICS_FUNC_ARGS); +int graphics_STKM(GRAPHICS_FUNC_ARGS); +int graphics_STKM2(GRAPHICS_FUNC_ARGS); #define UPDATE_FUNC_ARGS int i, int x, int y, int surround_space, int nt // to call another update function with same arguments: @@ -386,21 +404,6 @@ int run_stickman(float* playerp, UPDATE_FUNC_ARGS); void STKM_init_legs(float* playerp, int i); void STKM_interact(float* playerp, int i, int x, int y); - -struct particle -{ - int type; - int life, ctype; - float x, y, vx, vy; - float temp; - float pavg[2]; - int flags; - int tmp; - int tmp2; - unsigned int dcolour; -}; -typedef struct particle particle; - struct part_type { const char *name; @@ -513,7 +516,7 @@ static const part_type ptypes[PT_NUM] = {"NBLE", PIXPACK(0xEB4917), 1.0f, 0.01f * CFDS, 0.99f, 0.30f, -0.1f, 0.0f, 0.75f, 0.001f * CFDS, 0, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+2.0f +273.15f, 106, "Noble Gas. Diffuses. Conductive. Ionizes into plasma when introduced to electricity", ST_GAS, TYPE_GAS|PROP_CONDUCTS|PROP_LIFE_DEC, NULL, NULL}, {"BTRY", PIXPACK(0x858505), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Generates Electricity.", ST_SOLID, TYPE_SOLID, &update_BTRY, NULL}, {"LCRY", PIXPACK(0x505050), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_POWERED, R_TEMP+0.0f +273.15f, 251, "Liquid Crystal. Changes colour when charged. (PSCN Charges, NSCN Discharges)", ST_SOLID, TYPE_SOLID, &update_LCRY, &graphics_LCRY}, - {"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM, NULL}, + {"STKM", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM, &graphics_STKM}, {"SWCH", PIXPACK(0x103B11), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Solid. Only conducts when switched on. (PSCN switches on, NSCN switches off)", ST_SOLID, TYPE_SOLID, &update_SWCH, &graphics_SWCH}, {"SMKE", PIXPACK(0x222222), 0.9f, 0.04f * CFDS, 0.97f, 0.20f, 0.0f, -0.1f, 0.00f, 0.001f * CFDS, 1, 0, 0, 0, 1, 1, 1, 1, SC_GAS, R_TEMP+320.0f+273.15f, 88, "Smoke", ST_SOLID, TYPE_GAS|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, NULL, &graphics_SMKE}, {"DESL", PIXPACK(0x440000), 1.0f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.0f, 0.0f * CFDS, 2, 2, 0, 0, 5, 1, 1, 15, SC_LIQUID, R_TEMP+0.0f +273.15f, 42, "Liquid. Explodes under high pressure and temperatures", ST_LIQUID, TYPE_LIQUID, NULL, NULL}, @@ -586,7 +589,7 @@ static const part_type ptypes[PT_NUM] = {"FILT", PIXPACK(0x000056), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_SOLIDS, R_TEMP+0.0f +273.15f, 251, "Filter for photons, changes the color.", ST_SOLID, TYPE_SOLID, NULL, &graphics_FILT}, {"ARAY", PIXPACK(0xFFBB00), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 1, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Emitter. Rays create points when they collide", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC, &update_ARAY, NULL}, {"BRAY", PIXPACK(0xFFFFFF), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 1, 1, 0, 1, 100, SC_ELEC, R_TEMP+0.0f +273.15f, 251, "Ray Point. Rays create points when they collide", ST_SOLID, TYPE_SOLID|PROP_LIFE_DEC|PROP_LIFE_KILL, NULL, &graphics_BRAY}, - {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM2, NULL}, + {"STK2", PIXPACK(0x000000), 0.5f, 0.00f * CFDS, 0.2f, 1.0f, 0.0f, 0.0f, 0.0f, 0.00f * CFDS, 0, 0, 0, 0, 0, 1, 1, 50, SC_SPECIAL, R_TEMP+14.6f+273.15f, 0, "Stickman. Don't kill him!", ST_NONE, 0, &update_STKM2, &graphics_STKM2}, {"BOMB", PIXPACK(0xFFF288), 0.6f, 0.01f * CFDS, 0.98f, 0.95f, 0.0f, 0.1f, 0.00f, 0.000f * CFDS, 1, 0, 0, 0, 20, 1, 1, 30, SC_EXPLOSIVE, R_TEMP-2.0f +273.15f, 29, "Bomb.", ST_NONE, TYPE_PART|PROP_LIFE_DEC|PROP_LIFE_KILL_DEC, &update_BOMB, &graphics_BOMB}, {"C-5", PIXPACK(0x2050E0), 0.0f, 0.00f * CFDS, 0.90f, 0.00f, 0.0f, 0.0f, 0.00f, 0.000f * CFDS, 0, 0, 0, 0, 1, 1, 1, 100, SC_EXPLOSIVE, R_TEMP+0.0f +273.15f, 88, "Cold explosive", ST_SOLID, TYPE_SOLID | PROP_NEUTPENETRATE, &update_C5, NULL}, {"SING", PIXPACK(0x242424), 0.7f, 0.36f * CFDS, 0.96f, 0.80f, 0.1f, 0.12f, 0.00f, -0.001f * CFDS, 1, 0, 0, 0, 0, 1, 1, 86, SC_NUCLEAR, R_TEMP+0.0f +273.15f, 70, "Singularity", ST_SOLID, TYPE_PART|PROP_LIFE_DEC, &update_SING, NULL}, diff --git a/includes/powdergraphics.h b/includes/powdergraphics.h index 1040d488c..f59ead366 100644 --- a/includes/powdergraphics.h +++ b/includes/powdergraphics.h @@ -13,6 +13,8 @@ #define PMODE_ADD 0x00000080 #define PMODE_BLEND 0x00000100 +#define PSPEC_STICKMAN 0x00000200 + #define NO_DECO 0x00001000 #define FIREMODE 0x00FF0000 diff --git a/src/elements/deut.c b/src/elements/deut.c index bee375399..9276de17b 100644 --- a/src/elements/deut.c +++ b/src/elements/deut.c @@ -71,18 +71,18 @@ int update_DEUT(UPDATE_FUNC_ARGS) { int graphics_DEUT(GRAPHICS_FUNC_ARGS) { - if(parts[i].life>=700) + if(cpart->life>=700) { - *colr += parts[i].life*1; - *colg += parts[i].life*2; - *colb += parts[i].life*3; + *colr += cpart->life*1; + *colg += cpart->life*2; + *colb += cpart->life*3; *pixel_mode |= PMODE_GLOW; } else { - *colr += parts[i].life*1; - *colg += parts[i].life*2; - *colb += parts[i].life*3; + *colr += cpart->life*1; + *colg += cpart->life*2; + *colb += cpart->life*3; *pixel_mode |= PMODE_BLUR; } return 0; diff --git a/src/elements/fire.c b/src/elements/fire.c index 391c743b2..b16b6795f 100644 --- a/src/elements/fire.c +++ b/src/elements/fire.c @@ -2,7 +2,7 @@ int graphics_FIRE(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)flm_data[caddress]; *colg = (unsigned char)flm_data[caddress+1]; *colb = (unsigned char)flm_data[caddress+2]; diff --git a/src/elements/lava.c b/src/elements/lava.c index a748cf708..0a9fb8a34 100644 --- a/src/elements/lava.c +++ b/src/elements/lava.c @@ -2,9 +2,9 @@ int graphics_LAVA(GRAPHICS_FUNC_ARGS) { - *colr = parts[i].life * 2 + 0xE0; - *colg = parts[i].life * 1 + 0x50; - *colb = parts[i].life / 2 + 0x10; + *colr = cpart->life * 2 + 0xE0; + *colg = cpart->life * 1 + 0x50; + *colb = cpart->life / 2 + 0x10; if (*colr>255) *colr = 255; if (*colg>192) *colg = 192; if (*colb>128) *colb = 128; diff --git a/src/elements/newgraphics.c b/src/elements/newgraphics.c index 6f941e005..2f7be0388 100644 --- a/src/elements/newgraphics.c +++ b/src/elements/newgraphics.c @@ -1,11 +1,11 @@ #include int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT { - int t = parts[i].type, z = parts[i].tmp - 5;//speckles! - if (parts[i].temp>(ptransitions[t].thv-800.0f))//hotglow for quartz + int t = cpart->type, z = cpart->tmp - 5;//speckles! + if (cpart->temp>(ptransitions[t].thv-800.0f))//hotglow for quartz { float frequency = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - int q = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); + int q = (cpart->temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):cpart->temp-(ptransitions[t].thv-800.0f); *colr += sin(frequency*q) * 226 + (z * 16); *colg += sin(frequency*q*4.55 +3.14) * 34 + (z * 16); *colb += sin(frequency*q*2.22 +3.14) * 64 + (z * 16); @@ -20,7 +20,7 @@ int graphics_QRTZ(GRAPHICS_FUNC_ARGS) //QRTZ and PQRT } int graphics_CLST(GRAPHICS_FUNC_ARGS) { - int z = parts[i].tmp - 5;//speckles! + int z = cpart->tmp - 5;//speckles! *colr += z * 16; *colg += z * 16; *colb += z * 16; @@ -28,7 +28,7 @@ int graphics_CLST(GRAPHICS_FUNC_ARGS) } int graphics_CBNW(GRAPHICS_FUNC_ARGS) { - int z = parts[i].tmp2 - 20;//speckles! + int z = cpart->tmp2 - 20;//speckles! *colr += z * 1; *colg += z * 2; *colb += z * 8; @@ -36,9 +36,9 @@ int graphics_CBNW(GRAPHICS_FUNC_ARGS) } int graphics_SPNG(GRAPHICS_FUNC_ARGS) { - *colr -= parts[i].life*15; - *colg -= parts[i].life*15; - *colb -= parts[i].life*15; + *colr -= cpart->life*15; + *colg -= cpart->life*15; + *colb -= cpart->life*15; if (*colr<=50) *colr = 50; if (*colg<=50) @@ -50,50 +50,50 @@ int graphics_SPNG(GRAPHICS_FUNC_ARGS) int graphics_LIFE(GRAPHICS_FUNC_ARGS) { pixel pc; - if (parts[i].ctype==NGT_LOTE)//colors for life states + if (cpart->ctype==NGT_LOTE)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(255, 128, 0); - else if (parts[i].tmp==1) + else if (cpart->tmp==1) pc = PIXRGB(255, 255, 0); else pc = PIXRGB(255, 0, 0); } - else if (parts[i].ctype==NGT_FRG2)//colors for life states + else if (cpart->ctype==NGT_FRG2)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(0, 100, 50); else pc = PIXRGB(0, 255, 90); } - else if (parts[i].ctype==NGT_STAR)//colors for life states + else if (cpart->ctype==NGT_STAR)//colors for life states { - if (parts[i].tmp==4) + if (cpart->tmp==4) pc = PIXRGB(0, 0, 128); - else if (parts[i].tmp==3) + else if (cpart->tmp==3) pc = PIXRGB(0, 0, 150); - else if (parts[i].tmp==2) + else if (cpart->tmp==2) pc = PIXRGB(0, 0, 190); - else if (parts[i].tmp==1) + else if (cpart->tmp==1) pc = PIXRGB(0, 0, 230); else pc = PIXRGB(0, 0, 70); } - else if (parts[i].ctype==NGT_FROG)//colors for life states + else if (cpart->ctype==NGT_FROG)//colors for life states { - if (parts[i].tmp==2) + if (cpart->tmp==2) pc = PIXRGB(0, 100, 0); else pc = PIXRGB(0, 255, 0); } - else if (parts[i].ctype==NGT_BRAN)//colors for life states + else if (cpart->ctype==NGT_BRAN)//colors for life states { - if (parts[i].tmp==1) + if (cpart->tmp==1) pc = PIXRGB(150, 150, 0); else pc = PIXRGB(255, 255, 0); } else { - pc = gmenu[parts[i].ctype].colour; + pc = gmenu[cpart->ctype].colour; } *colr = PIXR(pc); *colg = PIXG(pc); @@ -102,17 +102,17 @@ int graphics_LIFE(GRAPHICS_FUNC_ARGS) } int graphics_DUST(GRAPHICS_FUNC_ARGS) { - if(parts[i].life >= 1) + if(cpart->life >= 1) { - *colr = parts[i].flags; - *colg = parts[i].tmp; - *colb = parts[i].ctype; - if (decorations_enable && parts[i].dcolour) + *colr = cpart->flags; + *colg = cpart->tmp; + *colb = cpart->ctype; + if (decorations_enable && cpart->dcolour) { - int a = (parts[i].dcolour>>24)&0xFF; - *colr = (a*((parts[i].dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((parts[i].dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((parts[i].dcolour)&0xFF) + (255-a)**colb) >> 8; + int a = (cpart->dcolour>>24)&0xFF; + *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; } *firea = 255; *firer = *colr; @@ -126,38 +126,38 @@ int graphics_GRAV(GRAPHICS_FUNC_ARGS) *colr = 20; *colg = 20; *colb = 20; - if (parts[i].vx>0) + if (cpart->vx>0) { - *colr += (parts[i].vx)*GRAV_R; - *colg += (parts[i].vx)*GRAV_G; - *colb += (parts[i].vx)*GRAV_B; + *colr += (cpart->vx)*GRAV_R; + *colg += (cpart->vx)*GRAV_G; + *colb += (cpart->vx)*GRAV_B; } - if (parts[i].vy>0) + if (cpart->vy>0) { - *colr += (parts[i].vy)*GRAV_G; - *colg += (parts[i].vy)*GRAV_B; - *colb += (parts[i].vy)*GRAV_R; + *colr += (cpart->vy)*GRAV_G; + *colg += (cpart->vy)*GRAV_B; + *colb += (cpart->vy)*GRAV_R; } - if (parts[i].vx<0) + if (cpart->vx<0) { - *colr -= (parts[i].vx)*GRAV_B; - *colg -= (parts[i].vx)*GRAV_R; - *colb -= (parts[i].vx)*GRAV_G; + *colr -= (cpart->vx)*GRAV_B; + *colg -= (cpart->vx)*GRAV_R; + *colb -= (cpart->vx)*GRAV_G; } - if (parts[i].vy<0) + if (cpart->vy<0) { - *colr -= (parts[i].vy)*GRAV_R2; - *colg -= (parts[i].vy)*GRAV_G2; - *colb -= (parts[i].vy)*GRAV_B2; + *colr -= (cpart->vy)*GRAV_R2; + *colg -= (cpart->vy)*GRAV_G2; + *colb -= (cpart->vy)*GRAV_B2; } return 0; } int graphics_WIFI(GRAPHICS_FUNC_ARGS) { float frequency = 0.0628; - int q = parts[i].tmp; + int q = cpart->tmp; *colr = sin(frequency*q + 0) * 127 + 128; *colg = sin(frequency*q + 2) * 127 + 128; *colb = sin(frequency*q + 4) * 127 + 128; @@ -192,75 +192,25 @@ int graphics_BIZR(GRAPHICS_FUNC_ARGS) //BIZR, BIZRG, BIZRS *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; - if(fabs(parts[i].vx)+fabs(parts[i].vy)>0) + if(fabs(cpart->vx)+fabs(cpart->vy)>0) { *firea = 255; - *fireg = *colg/5 * fabs(parts[i].vx)+fabs(parts[i].vy); - *fireb = *colb/5 * fabs(parts[i].vx)+fabs(parts[i].vy); - *firer = *colr/5 * fabs(parts[i].vx)+fabs(parts[i].vy); + *fireg = *colg/5 * fabs(cpart->vx)+fabs(cpart->vy); + *fireb = *colb/5 * fabs(cpart->vx)+fabs(cpart->vy); + *firer = *colr/5 * fabs(cpart->vx)+fabs(cpart->vy); *pixel_mode |= FIRE_ADD; } return 0; } -int graphics_PIPE(GRAPHICS_FUNC_ARGS) -{ - if (parts[i].ctype==2) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - else if (parts[i].ctype==3) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - else if (parts[i].ctype==4) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - else if (parts[i].temp<272.15&&parts[i].ctype!=1) - { - if (parts[i].temp>173.25&&parts[i].temp<273.15) - { - *colr = 50; - *colg = 1; - *colb = 1; - } - if (parts[i].temp>73.25&&parts[i].temp<=173.15) - { - *colr = 1; - *colg = 50; - *colb = 1; - } - if (parts[i].temp>=0&&parts[i].temp<=73.15) - { - *colr = 1; - *colg = 1; - *colb = 50; - } - } - if ((parts[i].tmp&0xFF)>0 && (parts[i].tmp&0xFF)4.0f || pv[ny/CELL][nx/CELL]<-4.0f) @@ -273,7 +223,7 @@ int graphics_INVS(GRAPHICS_FUNC_ARGS) } int graphics_ACID(GRAPHICS_FUNC_ARGS) { - int s = parts[i].life; + int s = cpart->life; if (s>75) s = 75; //These two should not be here. if (s<49) s = 49; s = (s-49)*3; @@ -286,19 +236,19 @@ int graphics_ACID(GRAPHICS_FUNC_ARGS) } int graphics_FILT(GRAPHICS_FUNC_ARGS) { - int x, temp_bin = (int)((parts[i].temp-273.0f)*0.025f); + int x, temp_bin = (int)((cpart->temp-273.0f)*0.025f); if (temp_bin < 0) temp_bin = 0; if (temp_bin > 25) temp_bin = 25; - parts[i].ctype = 0x1F << temp_bin; + cpart->ctype = 0x1F << temp_bin; *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; @@ -308,49 +258,49 @@ int graphics_FILT(GRAPHICS_FUNC_ARGS) int graphics_BRAY(GRAPHICS_FUNC_ARGS) { int x, trans = 255; - if(parts[i].tmp==0) + if(cpart->tmp==0) { - trans = parts[i].life * 7; + trans = cpart->life * 7; if (trans>255) trans = 255; - if (parts[i].ctype) { + if (cpart->ctype) { *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; } } - else if(parts[i].tmp==1) + else if(cpart->tmp==1) { - trans = parts[i].life/4; + trans = cpart->life/4; if (trans>255) trans = 255; - if (parts[i].ctype) { + if (cpart->ctype) { *colg = 0; *colb = 0; *colr = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; *colb *= x; } } - else if(parts[i].tmp==2) + else if(cpart->tmp==2) { - trans = parts[i].life*100; + trans = cpart->life*100; if (trans>255) trans = 255; *colr = 255; *colr = 150; @@ -363,7 +313,7 @@ int graphics_BRAY(GRAPHICS_FUNC_ARGS) } int graphics_SWCH(GRAPHICS_FUNC_ARGS) { - if(parts[i].life >= 10) + if(cpart->life >= 10) { *colr = 17; *colg = 217; @@ -383,25 +333,25 @@ int graphics_THDR(GRAPHICS_FUNC_ARGS) } int graphics_GLOW(GRAPHICS_FUNC_ARGS) { - *firer = restrict_flt(parts[i].temp-(275.13f+32.0f), 0, 128)/50.0f; - *fireg = restrict_flt(parts[i].ctype, 0, 128)/50.0f; - *fireb = restrict_flt(parts[i].tmp, 0, 128)/50.0f; + *firer = restrict_flt(cpart->temp-(275.13f+32.0f), 0, 128)/50.0f; + *fireg = restrict_flt(cpart->ctype, 0, 128)/50.0f; + *fireb = restrict_flt(cpart->tmp, 0, 128)/50.0f; - *colr = restrict_flt(64.0f+parts[i].temp-(275.13f+32.0f), 0, 255); - *colg = restrict_flt(64.0f+parts[i].ctype, 0, 255); - *colb = restrict_flt(64.0f+parts[i].tmp, 0, 255); + *colr = restrict_flt(64.0f+cpart->temp-(275.13f+32.0f), 0, 255); + *colg = restrict_flt(64.0f+cpart->ctype, 0, 255); + *colb = restrict_flt(64.0f+cpart->tmp, 0, 255); *pixel_mode |= FIRE_ADD; return 0; } int graphics_LCRY(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); - if(parts[i].dcolour && parts[i].dcolour&0xFF000000) + int lifemod = ((cpart->life>10?10:cpart->life)*10); + if(cpart->dcolour && cpart->dcolour&0xFF000000) { - *colr += (lifemod * (255-(parts[i].dcolour>>16)&0xFF))>>8; - *colg += (lifemod * (255-(parts[i].dcolour>>8)&0xFF))>>8; - *colb += (lifemod * (255-(parts[i].dcolour)&0xFF))>>8; + *colr += (lifemod * (255-(cpart->dcolour>>16)&0xFF))>>8; + *colg += (lifemod * (255-(cpart->dcolour>>8)&0xFF))>>8; + *colb += (lifemod * (255-(cpart->dcolour)&0xFF))>>8; } else { @@ -414,21 +364,21 @@ int graphics_LCRY(GRAPHICS_FUNC_ARGS) } int graphics_PCLN(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); + int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; *colg += lifemod; return 0; } int graphics_PBCN(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*10); + int lifemod = ((cpart->life>10?10:cpart->life)*10); *colr += lifemod; *colg += lifemod/2; return 0; } int graphics_DLAY(GRAPHICS_FUNC_ARGS) { - int stage = (int)(((float)parts[i].life/(parts[i].temp-273.15))*100.0f); + int stage = (int)(((float)cpart->life/(cpart->temp-273.15))*100.0f); *colr += stage; *colg += stage; *colb += stage; @@ -436,19 +386,19 @@ int graphics_DLAY(GRAPHICS_FUNC_ARGS) } int graphics_HSWC(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colr += lifemod; return 0; } int graphics_PVOD(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*16); + int lifemod = ((cpart->life>10?10:cpart->life)*16); *colr += lifemod; return 0; } int graphics_STOR(GRAPHICS_FUNC_ARGS) { - if(parts[i].tmp){ + if(cpart->tmp){ *colr = 0x50; *colg = 0xDF; *colb = 0xDF; @@ -461,20 +411,20 @@ int graphics_STOR(GRAPHICS_FUNC_ARGS) } int graphics_PUMP(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colb += lifemod; return 0; } int graphics_GPMP(GRAPHICS_FUNC_ARGS) { - int lifemod = ((parts[i].life>10?10:parts[i].life)*19); + int lifemod = ((cpart->life>10?10:cpart->life)*19); *colg += lifemod; *colb += lifemod; return 0; } int graphics_HFLM(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)hflm_data[caddress]; *colg = (unsigned char)hflm_data[caddress+1]; *colb = (unsigned char)hflm_data[caddress+2]; @@ -491,17 +441,17 @@ int graphics_HFLM(GRAPHICS_FUNC_ARGS) } int graphics_FIRW(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)((int)(parts[i].life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)((int)(cpart->life/2)), 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)firw_data[caddress]; *colg = (unsigned char)firw_data[caddress+1]; *colb = (unsigned char)firw_data[caddress+2]; - if (decorations_enable && parts[i].dcolour) + if (decorations_enable && cpart->dcolour) { - int a = (parts[i].dcolour>>24)&0xFF; - *colr = (a*((parts[i].dcolour>>16)&0xFF) + (255-a)**colr) >> 8; - *colg = (a*((parts[i].dcolour>>8)&0xFF) + (255-a)**colg) >> 8; - *colb = (a*((parts[i].dcolour)&0xFF) + (255-a)**colb) >> 8; + int a = (cpart->dcolour>>24)&0xFF; + *colr = (a*((cpart->dcolour>>16)&0xFF) + (255-a)**colr) >> 8; + *colg = (a*((cpart->dcolour>>8)&0xFF) + (255-a)**colg) >> 8; + *colb = (a*((cpart->dcolour)&0xFF) + (255-a)**colb) >> 8; } *firea = 255; @@ -516,7 +466,7 @@ int graphics_FIRW(GRAPHICS_FUNC_ARGS) } int graphics_BOMB(GRAPHICS_FUNC_ARGS) { - if (parts[i].tmp==0) { + if (cpart->tmp==0) { *pixel_mode |= PMODE_FLARE; } else @@ -527,7 +477,7 @@ int graphics_BOMB(GRAPHICS_FUNC_ARGS) } int graphics_GBMB(GRAPHICS_FUNC_ARGS) { - if (parts[i].life <= 0) { + if (cpart->life <= 0) { *pixel_mode |= PMODE_FLARE; } else @@ -538,7 +488,7 @@ int graphics_GBMB(GRAPHICS_FUNC_ARGS) } int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal { - *colr += (parts[i].tmp2-295.15f)/3; + *colr += (cpart->tmp2-295.15f)/3; if (*colr > 170) *colr = 170; @@ -547,10 +497,10 @@ int graphics_COAL(GRAPHICS_FUNC_ARGS) //Both COAL and Broken Coal *colg = *colb = *colr; - if((parts[i].temp-295.15f) > 300.0f-200.0f) + if((cpart->temp-295.15f) > 300.0f-200.0f) { float frequency = 3.1415/(2*300.0f-(300.0f-200.0f)); - int q = ((parts[i].temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(parts[i].temp-295.15f)-(300.0f-200.0f); + int q = ((cpart->temp-295.15f)>300.0f)?300.0f-(300.0f-200.0f):(cpart->temp-295.15f)-(300.0f-200.0f); *colr += sin(frequency*q) * 226; *colg += sin(frequency*q*4.55 +3.14) * 34; diff --git a/src/elements/phot.c b/src/elements/phot.c index f9997539f..7a9d4f2cd 100644 --- a/src/elements/phot.c +++ b/src/elements/phot.c @@ -64,11 +64,11 @@ int graphics_PHOT(GRAPHICS_FUNC_ARGS) int x = 0; *colr = *colg = *colb = 0; for (x=0; x<12; x++) { - *colr += (parts[i].ctype >> (x+18)) & 1; - *colb += (parts[i].ctype >> x) & 1; + *colr += (cpart->ctype >> (x+18)) & 1; + *colb += (cpart->ctype >> x) & 1; } for (x=0; x<12; x++) - *colg += (parts[i].ctype >> (x+9)) & 1; + *colg += (cpart->ctype >> (x+9)) & 1; x = 624/(*colr+*colg+*colb+1); *colr *= x; *colg *= x; diff --git a/src/elements/pipe.c b/src/elements/pipe.c index 741193259..701453640 100644 --- a/src/elements/pipe.c +++ b/src/elements/pipe.c @@ -235,3 +235,85 @@ int update_PIPE(UPDATE_FUNC_ARGS) { } return 0; } + +int graphics_PIPE(GRAPHICS_FUNC_ARGS) +{ + if (cpart->ctype==2) + { + *colr = 50; + *colg = 1; + *colb = 1; + } + else if (cpart->ctype==3) + { + *colr = 1; + *colg = 50; + *colb = 1; + } + else if (cpart->ctype==4) + { + *colr = 1; + *colg = 1; + *colb = 50; + } + else if (cpart->temp<272.15&&cpart->ctype!=1) + { + if (cpart->temp>173.25&&cpart->temp<273.15) + { + *colr = 50; + *colg = 1; + *colb = 1; + } + if (cpart->temp>73.25&&cpart->temp<=173.15) + { + *colr = 1; + *colg = 50; + *colb = 1; + } + if (cpart->temp>=0&&cpart->temp<=73.15) + { + *colr = 1; + *colg = 1; + *colb = 50; + } + } + if ((cpart->tmp&0xFF)>0 && (cpart->tmp&0xFF)tmp&0xFF; + tpart.temp = cpart->temp; + tpart.life = cpart->flags; + tpart.tmp = cpart->pavg[0]; + tpart.ctype = cpart->pavg[1]; + t = tpart.type; + if (graphicscache[t].isready) + { + *pixel_mode = graphicscache[t].pixel_mode; + *colr = graphicscache[t].colr; + *colg = graphicscache[t].colg; + *colb = graphicscache[t].colb; + *firea = graphicscache[t].firea; + *firer = graphicscache[t].firer; + *fireg = graphicscache[t].fireg; + *fireb = graphicscache[t].fireb; + } + else + { + if (ptypes[t].graphics_func) + { + (*(ptypes[t].graphics_func))(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb); + } + else + { + graphics_DEFAULT(&tpart, nx, ny, pixel_mode, colr, colg, colb, firea, firer, fireg, fireb); + } + } + //*colr = PIXR(ptypes[cpart->tmp&0xFF].pcolors); + //*colg = PIXG(ptypes[cpart->tmp&0xFF].pcolors); + //*colb = PIXB(ptypes[cpart->tmp&0xFF].pcolors); + } + return 0; +} diff --git a/src/elements/plsm.c b/src/elements/plsm.c index 3bab69377..6cd02754f 100644 --- a/src/elements/plsm.c +++ b/src/elements/plsm.c @@ -2,7 +2,7 @@ int graphics_PLSM(GRAPHICS_FUNC_ARGS) { - int caddress = restrict_flt(restrict_flt((float)parts[i].life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); + int caddress = restrict_flt(restrict_flt((float)cpart->life, 0.0f, 200.0f)*3, 0.0f, (200.0f*3)-3); *colr = (unsigned char)plasma_data[caddress]; *colg = (unsigned char)plasma_data[caddress+1]; *colb = (unsigned char)plasma_data[caddress+2]; diff --git a/src/elements/stkm.c b/src/elements/stkm.c index a96de2aee..752f167d0 100644 --- a/src/elements/stkm.c +++ b/src/elements/stkm.c @@ -13,6 +13,22 @@ int update_STKM(UPDATE_FUNC_ARGS) return 0; } +int graphics_STKM(GRAPHICS_FUNC_ARGS) +{ + *pixel_mode = PSPEC_STICKMAN; + if ((int)player[2]>8)&0xFF; decb = (parts[i].dcolour)&0xFF; - if (ptypes[t].graphics_func) + if (graphicscache[t].isready) { - if ((*(ptypes[t].graphics_func))(i, nx, ny, &pixel_mode, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better - { - //Data can be cached! - } + pixel_mode = graphicscache[t].pixel_mode; + colr = graphicscache[t].colr; + colg = graphicscache[t].colg; + colb = graphicscache[t].colb; + firea = graphicscache[t].firea; + firer = graphicscache[t].firer; + fireg = graphicscache[t].fireg; + fireb = graphicscache[t].fireb; } else { - //Property based defaults - if(ptypes[t].properties & PROP_RADIOACTIVE) pixel_mode |= PMODE_GLOW; - if(ptypes[t].properties & PROP_HOT_GLOW && parts[i].temp>(ptransitions[t].thv-800.0f)) + if (ptypes[t].graphics_func) { - gradv = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); - caddress = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); - colr += sin(gradv*caddress) * 226;; - colg += sin(gradv*caddress*4.55 +3.14) * 34; - colb += sin(gradv*caddress*2.22 +3.14) * 64; + if ((*(ptypes[t].graphics_func))(&(parts[i]), nx, ny, &pixel_mode, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) //That's a lot of args, a struct might be better + { + graphicscache[t].isready = 1; + graphicscache[t].pixel_mode = pixel_mode; + graphicscache[t].colr = colr; + graphicscache[t].colg = colg; + graphicscache[t].colb = colb; + graphicscache[t].firea = firea; + graphicscache[t].firer = firer; + graphicscache[t].fireg = fireg; + graphicscache[t].fireb = fireb; + } } - if(ptypes[t].properties & TYPE_LIQUID) + else { - pixel_mode |= PMODE_BLUR; - } - if(ptypes[t].properties & TYPE_GAS) - { - pixel_mode &= ~PMODE; - pixel_mode |= FIRE_BLEND; - firer = colr/2; - fireg = colg/2; - fireb = colb/2; - firea = 125; + if(graphics_DEFAULT(&(parts[i]), nx, ny, &pixel_mode, &colr, &colg, &colb, &firea, &firer, &fireg, &fireb)) + { + graphicscache[t].isready = 1; + graphicscache[t].pixel_mode = pixel_mode; + graphicscache[t].colr = colr; + graphicscache[t].colg = colg; + graphicscache[t].colb = colb; + graphicscache[t].firea = firea; + graphicscache[t].firer = firer; + graphicscache[t].fireg = fireg; + graphicscache[t].fireb = fireb; + } } } - + if(ptypes[t].properties & PROP_HOT_GLOW && parts[i].temp>(ptransitions[t].thv-800.0f)) + { + gradv = 3.1415/(2*ptransitions[t].thv-(ptransitions[t].thv-800.0f)); + caddress = (parts[i].temp>ptransitions[t].thv)?ptransitions[t].thv-(ptransitions[t].thv-800.0f):parts[i].temp-(ptransitions[t].thv-800.0f); + colr += sin(gradv*caddress) * 226;; + colg += sin(gradv*caddress*4.55 +3.14) * 34; + colb += sin(gradv*caddress*2.22 +3.14) * 64; + } if(cmode == CM_NOTHING) { #ifdef OGLR @@ -1588,6 +1620,95 @@ void render_parts(pixel *vid) else if(colb<0) colb = 0; //Pixel rendering + if(pixel_mode & PSPEC_STICKMAN) + { + //Special case for stickman +#ifdef OGLR + float *cplayer; + if(t==PT_STKM) + cplayer = player; + else + cplayer = player2; + glColor4f(((float)colr)/255.0f, ((float)colg)/255.0f, ((float)colb)/255.0f, 1.0f); + glEnable(GL_LINE_SMOOTH); + glBegin(GL_LINE_STRIP); + glVertex2f(fnx-2, fny-2); + glVertex2f(fnx+2, fny-2); + glVertex2f(fnx+2, fny+2); + glVertex2f(fnx-2, fny+2); + glVertex2f(fnx-2, fny-2); + glEnd(); + if(t==PT_STKM) + glColor4f(1.0f, 1.0f, 1.0f, 1.0f); + else + glColor4f(0.6f, 0.6f, 1.0f, 1.0f); + glBegin(GL_LINES); + glVertex2f(nx, ny+3); + glVertex2f(cplayer[3], cplayer[4]); + + glVertex2f(cplayer[3], cplayer[4]); + glVertex2f(cplayer[7], cplayer[8]); + + glVertex2f(nx, ny+3); + glVertex2f(cplayer[11], cplayer[12]); + + glVertex2f(cplayer[11], cplayer[12]); + glVertex2f(cplayer[15], cplayer[16]); + glEnd(); + glDisable(GL_LINE_SMOOTH); +#else + if (t==PT_STKM) + { + char buff[20]; //Buffer for HP + pixel pc; + + if (mousex>(nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head + { + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); + } + + if ((int)player[2](nx-3) && mousex<(nx+3) && mousey<(ny+3) && mousey>(ny-3)) //If mous is in the head + { + sprintf(buff, "%3d", parts[i].life); //Show HP + drawtext(vid, mousex-8-2*(parts[i].life<100)-2*(parts[i].life<10), mousey-12, buff, 255, 255, 255, 255); + } + + if ((int)player2[2]