summaryrefslogtreecommitdiff
path: root/src/graphics.c
diff options
context:
space:
mode:
authorFelix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
committer Felix Wallin <nibbler.v1@gmail.com>2010-12-20 13:34:55 (GMT)
commit14b4dfef87892ad744cbb8b6fbdc0bc80044d51b (patch)
treea50bde6af1f0df4ecc8ed512ccfd5a9010b93a0b /src/graphics.c
parentcb6597f9e192b13546295c030ad98bad4f041648 (diff)
downloadpowder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.zip
powder-14b4dfef87892ad744cbb8b6fbdc0bc80044d51b.tar.gz
nice
Diffstat (limited to 'src/graphics.c')
-rw-r--r--src/graphics.c798
1 files changed, 399 insertions, 399 deletions
diff --git a/src/graphics.c b/src/graphics.c
index 3ea4c9c..a98b66b 100644
--- a/src/graphics.c
+++ b/src/graphics.c
@@ -745,10 +745,10 @@ int draw_tool_xy(pixel *vid_buf, int x, int y, int b, unsigned pc)
void draw_menu(pixel *vid_buf, int i, int hover)
{
- if(i==SEC&&SEC!=0)
- drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 0, 255, 255, 255);
- else
- drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
+ if(i==SEC&&SEC!=0)
+ drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 0, 255, 255, 255);
+ else
+ drawrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
if(hover==i)
{
fillrect(vid_buf, (XRES+BARSIZE)-16, (i*16)+YRES+MENUSIZE-16-(SC_TOTAL*16), 14, 14, 255, 255, 255, 255);
@@ -1008,22 +1008,22 @@ int textnwidth(char *s, int n)
void textnpos(char *s, int n, int w, int *cx, int *cy)
{
int x = 0;
- int y = 0;
- //TODO: Implement Textnheight for wrapped text
- for(; *s; s++)
+ int y = 0;
+ //TODO: Implement Textnheight for wrapped text
+ for(; *s; s++)
{
- if(!n){
+ if(!n) {
break;
- }
+ }
x += font_data[font_ptrs[(int)(*(unsigned char *)s)]];
- if(x>=w) {
- x = 0;
- y += FONT_H+2;
- }
+ if(x>=w) {
+ x = 0;
+ y += FONT_H+2;
+ }
n--;
}
*cx = x-1;
- *cy = y;
+ *cy = y;
}
int textwidthx(char *s, int w)
@@ -1048,10 +1048,10 @@ int textposxy(char *s, int width, int w, int h)
if(x+(cw/2) >= w && y+6 >= h)
break;
x += cw;
- if(x>=width) {
- x = 0;
- y += FONT_H+2;
- }
+ if(x>=width) {
+ x = 0;
+ y += FONT_H+2;
+ }
n++;
}
return n;
@@ -1124,42 +1124,42 @@ void draw_air(pixel *vid)
c = PIXRGB(0, 0, clamp_flt(-pv[y][x], 0.0f, 8.0f));
}
else if(cmode == CM_VEL)
- {
+ {
c = PIXRGB(clamp_flt(fabsf(vx[y][x]), 0.0f, 8.0f),
clamp_flt(pv[y][x], 0.0f, 8.0f),
clamp_flt(fabsf(vy[y][x]), 0.0f, 8.0f));
- }
- else if(cmode == CM_CRACK)
- {
- int r;
- int g;
- int b;
- r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
- g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f);
- b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
- if(pv[y][x] > 0.0f)
- {
- r += clamp_flt(pv[y][x], 0.0f, 16.0f);
- if(r>255)
- r=255;
- if(g>255)
- g=255;
- if(b>255)
- b=255;
- c = PIXRGB(r, g, b);
- }
- else
- {
- b += clamp_flt(-pv[y][x], 0.0f, 16.0f);
- if(r>255)
- r=255;
- if(g>255)
- g=255;
- if(b>255)
- b=255;
- c = PIXRGB(r, g, b);
- }
- }
+ }
+ else if(cmode == CM_CRACK)
+ {
+ int r;
+ int g;
+ int b;
+ r = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ g = clamp_flt(fabsf(vx[y][x]), 0.0f, 20.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 24.0f);
+ b = clamp_flt(fabsf(vx[y][x]), 0.0f, 24.0f) + clamp_flt(fabsf(vy[y][x]), 0.0f, 20.0f);
+ if(pv[y][x] > 0.0f)
+ {
+ r += clamp_flt(pv[y][x], 0.0f, 16.0f);
+ if(r>255)
+ r=255;
+ if(g>255)
+ g=255;
+ if(b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
+ }
+ else
+ {
+ b += clamp_flt(-pv[y][x], 0.0f, 16.0f);
+ if(r>255)
+ r=255;
+ if(g>255)
+ g=255;
+ if(b>255)
+ b=255;
+ c = PIXRGB(r, g, b);
+ }
+ }
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
vid[(x*CELL+i) + (y*CELL+j)*(XRES+BARSIZE)] = c;
@@ -1305,16 +1305,16 @@ void draw_parts(pixel *vid)
float fr, fg, fb;
float pt = R_TEMP;
if(GRID_MODE)
- {
- for(ny=0;ny<YRES;ny++)
- for(nx=0;nx<XRES;nx++)
- {
- if(ny%(4*GRID_MODE)==0)
- blendpixel(vid, nx, ny, 100, 100, 100, 80);
- if(nx%(4*GRID_MODE)==0)
- blendpixel(vid, nx, ny, 100, 100, 100, 80);
- }
- }
+ {
+ for(ny=0; ny<YRES; ny++)
+ for(nx=0; nx<XRES; nx++)
+ {
+ if(ny%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ if(nx%(4*GRID_MODE)==0)
+ blendpixel(vid, nx, ny, 100, 100, 100, 80);
+ }
+ }
for(i = 0; i<NPART; i++) {
#ifdef OpenGL
if(cmode == CM_FANCY) //If fancy mode
@@ -1402,7 +1402,7 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
- else if(t==PT_STKM2) //Just draw head here
+ else if(t==PT_STKM2) //Just draw head here
{
char buff[10]; //Buffer for HP
@@ -1427,82 +1427,82 @@ void draw_parts(pixel *vid)
isplayer2 = 1; //It's a secret. Tssss...
}
- if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes
- {
- if(t==PT_PHOT)
- {
- 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, 255);
- }
- else
- {
- cr = PIXR(ptypes[t].pcolors);
- cg = PIXG(ptypes[t].pcolors);
- cb = PIXB(ptypes[t].pcolors);
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- }
- }
- else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
- {
- if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
- {
- float frequency = 0.00146;
- int q = parts[i].temp-473;
- cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
- cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
- cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors);
- 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
- {
- float frequency = 0.05;
- int q = parts[i].temp-40;
- cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
- cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
- cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
- 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);
- }
-
- }
+ if(cmode==CM_NOTHING && t!=PT_PIPE && t!=PT_SWCH && t!=PT_LCRY && t!=PT_PUMP && t!=PT_FILT && t!=PT_HSWC && t!=PT_PCLN && t!=PT_DEUT && t!=PT_WIFI)//nothing display but show needed color changes
+ {
+ if(t==PT_PHOT)
+ {
+ 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, 255);
+ }
+ else
+ {
+ cr = PIXR(ptypes[t].pcolors);
+ cg = PIXG(ptypes[t].pcolors);
+ cb = PIXB(ptypes[t].pcolors);
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ }
+ else if(cmode==CM_GRAD)//forgot to put else, broke nothing view
+ {
+ if((t==PT_METL||t==PT_BRMT||t==PT_BMTL)&&parts[i].temp>473&&parts[i].temp<1370)
+ {
+ float frequency = 0.00146;
+ int q = parts[i].temp-473;
+ cr = sin(frequency*q) * 226 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q*4.55 +3.14) * 34 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q*2.22 +3.14) * 64 + PIXB(ptypes[t].pcolors);
+ 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
+ {
+ float frequency = 0.05;
+ int q = parts[i].temp-40;
+ cr = sin(frequency*q) * 16 + PIXR(ptypes[t].pcolors);
+ cg = sin(frequency*q) * 16 + PIXG(ptypes[t].pcolors);
+ cb = sin(frequency*q) * 16 + PIXB(ptypes[t].pcolors);
+ 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_MWAX&&cmode == CM_FANCY)
{
for(x=-1; x<=1; x++)
@@ -1519,30 +1519,30 @@ void draw_parts(pixel *vid)
}
}
- else if(t==PT_SPNG)
- {
+ else if(t==PT_SPNG)
+ {
cr = PIXR(ptypes[t].pcolors) - parts[i].life*15;
cg = PIXG(ptypes[t].pcolors) - parts[i].life*15;
cb = PIXB(ptypes[t].pcolors) - parts[i].life*15;
- if(cr<=50)
- cr = 50;
- if(cg<=50)
- cg = 50;
- if(cb<=20)
- cb = 20;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
-
- }
- else if(t==PT_DEUT)
- {
-
- if(parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY))
- {
- x = nx/CELL;
+ if(cr<=50)
+ cr = 50;
+ if(cg<=50)
+ cg = 50;
+ if(cb<=20)
+ cb = 20;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+ }
+ else if(t==PT_DEUT)
+ {
+
+ if(parts[i].life>=700&&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY))
+ {
+ x = nx/CELL;
y = ny/CELL;
- cr = 20;
- cg = 20;
- cb = 20;
+ cr = 20;
+ cg = 20;
+ cb = 20;
cg += fire_g[y][x];
if(cg > 255) cg = 255;
fire_g[y][x] = cg;
@@ -1552,28 +1552,28 @@ void draw_parts(pixel *vid)
cr += fire_r[y][x];
if(cr > 255) cr = 255;
fire_r[y][x] = cr;
- }
- else
- {
- 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);
-
- }
-
- }
- else if(t==PT_DUST && parts[i].life >= 1)
+ }
+ else
+ {
+ 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);
+
+ }
+
+ }
+ else if(t==PT_DUST && parts[i].life >= 1)
{
x = nx;
y = ny;
- if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
+ if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
{
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(parts[i].tmp,parts[i].ctype,parts[i].flags);
cg = parts[i].tmp/4;
@@ -1591,94 +1591,94 @@ void draw_parts(pixel *vid)
if(cr > 255) cr = 255;
fire_r[y][x] = cr;
}
- else
- blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255);
- }
- else if(t==PT_GRAV)
- {
- cr = 20;
- cg = 20;
- cb = 20;
- if(parts[i].vx>0)
- {
- cr += (parts[i].vx)*GRAV_R;
- cg += (parts[i].vx)*GRAV_G;
- cb += (parts[i].vx)*GRAV_B;
- }
- if(parts[i].vy>0)
- {
- cr += (parts[i].vy)*GRAV_G;
- cg += (parts[i].vy)*GRAV_B;
- cb += (parts[i].vy)*GRAV_R;
-
- }
- if(parts[i].vx<0)
- {
- cr -= (parts[i].vx)*GRAV_B;
- cg -= (parts[i].vx)*GRAV_R;
- cb -= (parts[i].vx)*GRAV_G;
-
- }
- if(parts[i].vy<0)
- {
- cr -= (parts[i].vy)*GRAV_R2;
- cg -= (parts[i].vy)*GRAV_G2;
- cb -= (parts[i].vy)*GRAV_B2;
- }
- if(cr>255)
- cr=255;
- if(cg>255)
- cg=255;
- if(cb>255)
- cb=255;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- }
- else if(t==PT_WIFI)
- {
- float frequency = 0.0628;
- int q = parts[i].tmp;
- cr = sin(frequency*q + 0) * 127 + 128;
- cg = sin(frequency*q + 2) * 127 + 128;
- cb = sin(frequency*q + 4) * 127 + 128;
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- if(mousex==(nx) && mousey==(ny))
- {
- int z;
+ else
+ blendpixel(vid,x,y,parts[i].tmp,parts[i].ctype,parts[i].flags,255);
+ }
+ else if(t==PT_GRAV)
+ {
+ cr = 20;
+ cg = 20;
+ cb = 20;
+ if(parts[i].vx>0)
+ {
+ cr += (parts[i].vx)*GRAV_R;
+ cg += (parts[i].vx)*GRAV_G;
+ cb += (parts[i].vx)*GRAV_B;
+ }
+ if(parts[i].vy>0)
+ {
+ cr += (parts[i].vy)*GRAV_G;
+ cg += (parts[i].vy)*GRAV_B;
+ cb += (parts[i].vy)*GRAV_R;
+
+ }
+ if(parts[i].vx<0)
+ {
+ cr -= (parts[i].vx)*GRAV_B;
+ cg -= (parts[i].vx)*GRAV_R;
+ cb -= (parts[i].vx)*GRAV_G;
+
+ }
+ if(parts[i].vy<0)
+ {
+ cr -= (parts[i].vy)*GRAV_R2;
+ cg -= (parts[i].vy)*GRAV_G2;
+ cb -= (parts[i].vy)*GRAV_B2;
+ }
+ if(cr>255)
+ cr=255;
+ if(cg>255)
+ cg=255;
+ if(cb>255)
+ cb=255;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ else if(t==PT_WIFI)
+ {
+ float frequency = 0.0628;
+ int q = parts[i].tmp;
+ cr = sin(frequency*q + 0) * 127 + 128;
+ cg = sin(frequency*q + 2) * 127 + 128;
+ cb = sin(frequency*q + 4) * 127 + 128;
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ if(mousex==(nx) && mousey==(ny))
+ {
+ int z;
for(z = 0; z<NPART; z++) {
- if(parts[z].type)
- {
- if(parts[z].type==PT_WIFI&&parts[z].tmp==parts[i].tmp)
- xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
- }
- }
- }
- }
- else if((t==PT_BIZR||t==PT_BIZRG)&&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;
- if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
- fg = 0;
- fb = 0;
- fr = 0;
+ if(parts[z].type)
+ {
+ if(parts[z].type==PT_WIFI&&parts[z].tmp==parts[i].tmp)
+ xor_line(nx,ny,(int)(parts[z].x+0.5f),(int)(parts[z].y+0.5f),vid);
+ }
+ }
+ }
+ }
+ else if((t==PT_BIZR||t==PT_BIZRG)&&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;
+ if(fabs(parts[i].vx)+fabs(parts[i].vy)>0 &&(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)) {
+ fg = 0;
+ fb = 0;
+ fr = 0;
fg = cg/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fb = cb/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
fr = cr/40 * fabs(parts[i].vx)+fabs(parts[i].vy);
- vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
+ vid[ny*(XRES+BARSIZE)+nx] = PIXRGB((int)restrict_flt(cr, 0, 255), (int)restrict_flt(cg, 0, 255), (int)restrict_flt(cb, 0, 255));
x = nx/CELL;
y = ny/CELL;
fg += fire_g[y][x];
@@ -1690,70 +1690,70 @@ void draw_parts(pixel *vid)
fr += fire_r[y][x];
if(fr > 255) fr = 255;
fire_r[y][x] = fr;
- }
- else
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
- }
- else if(t==PT_PIPE)
- {
- if(parts[i].ctype==2)
- {
- cr = 50;
- cg = 1;
- cb = 1;
- }
- else if(parts[i].ctype==3)
- {
- cr = 1;
- cg = 50;
- cb = 1;
- }
- else if(parts[i].ctype==4)
- {
- cr = 1;
- cg = 1;
- cb = 50;
- }
- else if(parts[i].temp<272.15&&parts[i].ctype!=1)
- {
- if(parts[i].temp>173.25&&parts[i].temp<273.15)
- {
- cr = 50;
- cg = 1;
- cb = 1;
- }
- if(parts[i].temp>73.25&&parts[i].temp<=173.15)
- {
- cr = 1;
- cg = 50;
- cb = 1;
- }
- if(parts[i].temp>=0&&parts[i].temp<=73.15)
- {
- cr = 1;
- cg = 1;
- cb = 50;
- }
- }
- else
- {
- cr = PIXR(ptypes[t].pcolors);
- cg = PIXG(ptypes[t].pcolors);
- cb = PIXB(ptypes[t].pcolors);
- }
- if(parts[i].tmp)
- {
- cr = PIXR(ptypes[parts[i].tmp].pcolors);
- cg = PIXG(ptypes[parts[i].tmp].pcolors);
- cb = PIXB(ptypes[parts[i].tmp].pcolors);
- }
- blendpixel(vid, nx, ny, cr, cg, cb, 255);
-
-
-
- }
- 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
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+ }
+ else if(t==PT_PIPE)
+ {
+ if(parts[i].ctype==2)
+ {
+ cr = 50;
+ cg = 1;
+ cb = 1;
+ }
+ else if(parts[i].ctype==3)
+ {
+ cr = 1;
+ cg = 50;
+ cb = 1;
+ }
+ else if(parts[i].ctype==4)
+ {
+ cr = 1;
+ cg = 1;
+ cb = 50;
+ }
+ else if(parts[i].temp<272.15&&parts[i].ctype!=1)
+ {
+ if(parts[i].temp>173.25&&parts[i].temp<273.15)
+ {
+ cr = 50;
+ cg = 1;
+ cb = 1;
+ }
+ if(parts[i].temp>73.25&&parts[i].temp<=173.15)
+ {
+ cr = 1;
+ cg = 50;
+ cb = 1;
+ }
+ if(parts[i].temp>=0&&parts[i].temp<=73.15)
+ {
+ cr = 1;
+ cg = 1;
+ cb = 50;
+ }
+ }
+ else
+ {
+ cr = PIXR(ptypes[t].pcolors);
+ cg = PIXG(ptypes[t].pcolors);
+ cb = PIXB(ptypes[t].pcolors);
+ }
+ if(parts[i].tmp)
+ {
+ cr = PIXR(ptypes[parts[i].tmp].pcolors);
+ cg = PIXG(ptypes[parts[i].tmp].pcolors);
+ cb = PIXB(ptypes[parts[i].tmp].pcolors);
+ }
+ blendpixel(vid, nx, ny, cr, cg, cb, 255);
+
+
+
+ }
+ 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;
@@ -1888,45 +1888,45 @@ void draw_parts(pixel *vid)
}
}
}
- else if(t==PT_FILT)
- {
- int temp_bin = (int)((parts[i].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;
- 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, 127);
- }
- 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);
- }
- 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);
- }
- else if(t==PT_BRAY && parts[i].tmp==2)
- {
- int trans = parts[i].life*100;
- blendpixel(vid, nx, ny, 255, 150, 50, trans);
- }
+ else if(t==PT_FILT)
+ {
+ int temp_bin = (int)((parts[i].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;
+ 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, 127);
+ }
+ 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);
+ }
+ 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);
+ }
+ else if(t==PT_BRAY && parts[i].tmp==2)
+ {
+ int trans = parts[i].life*100;
+ blendpixel(vid, nx, ny, 255, 150, 50, trans);
+ }
else if(t==PT_PHOT)
{
if(cmode == CM_FIRE||cmode==CM_BLOB || cmode==CM_FANCY)
@@ -2291,7 +2291,7 @@ void draw_parts(pixel *vid)
blendpixel(vid, nx-1, ny+1, GR, 10, 10, 112);
}
}
- else if(t==PT_PUMP)
+ else if(t==PT_PUMP)
{
uint8 GR = 0x3B+(parts[i].life*19);
vid[ny*(XRES+BARSIZE)+nx] = PIXRGB(10, 10, GR);
@@ -2604,7 +2604,7 @@ void draw_parts(pixel *vid)
isplayer = 1; //It's a secret. Tssss...
}
- else if(t==PT_STKM2) //Stick man should be visible in heat mode
+ else if(t==PT_STKM2) //Stick man should be visible in heat mode
{
char buff[10]; //Buffer for HP
@@ -2723,15 +2723,15 @@ void render_signs(pixel *vid_buf)
x+=dx;
y+=dy;
}
- if(MSIGN==i)
- {
- bq = b;
- b = SDL_GetMouseState(&mx, &my);
- mx /= sdl_scale;
- my /= sdl_scale;
- signs[i].x = mx;
- signs[i].y = my;
- }
+ if(MSIGN==i)
+ {
+ bq = b;
+ b = SDL_GetMouseState(&mx, &my);
+ mx /= sdl_scale;
+ my /= sdl_scale;
+ signs[i].x = mx;
+ signs[i].y = my;
+ }
}
}
@@ -2961,12 +2961,12 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
if(!(j%2) && !(i%2))
fb[(ry+j)*w+(rx+i)] = PIXPACK(0xC0C0C0);
break;
- case 4:
- for(j=0; j<CELL; j+=2)
- for(i=(j>>1)&1; i<CELL; i+=2)
- fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
- k++;
- break;
+ case 4:
+ for(j=0; j<CELL; j+=2)
+ for(i=(j>>1)&1; i<CELL; i+=2)
+ fb[(ry+j)*w+(rx+i)] = PIXPACK(0x8080FF);
+ k++;
+ break;
case 6:
for(j=0; j<CELL; j+=2)
for(i=(j>>1)&1; i<CELL; i+=2)
@@ -2986,7 +2986,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
else
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
break;
- case WL_WALL:
+ case WL_WALL:
for(j=0; j<CELL; j++)
for(i=0; i<CELL; i++)
fb[(ry+j)*w+(rx+i)] = PIXPACK(0x808080);
@@ -3057,7 +3057,7 @@ pixel *prerender_save(void *save, int size, int *width, int *height)
draw_line(fb , x, y+3, x+1, y+6, 255, 255, 255, w);
draw_line(fb , x+1, y+6, x+3, y+12, 255, 255, 255, w);
}
- else if(j==PT_STKM2)
+ else if(j==PT_STKM2)
{
//Stickman drawing
for(k=-2; k<=1; k++)
@@ -3177,27 +3177,27 @@ corrupt:
void render_cursor(pixel *vid, int x, int y, int t, int rx, int ry)
{
- int i,j,c;
+ int i,j,c;
if(t<PT_NUM||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM)
{
- if(rx<=0)
+ if(rx<=0)
xor_pixel(x, y, vid);
- else if(ry<=0)
+ else if(ry<=0)
xor_pixel(x, y, vid);
- if(rx+ry<=0)
+ if(rx+ry<=0)
xor_pixel(x, y, vid);
- else if(CURRENT_BRUSH==SQUARE_BRUSH)
- {
- for(j=0; j<=ry; j++)
- for(i=0; i<=rx; i++)
- if(i*j<=ry*rx && ((i+1)>rx || (j+1)>ry))
- {
- xor_pixel(x+i, y+j, vid);
- xor_pixel(x-i, y-j, vid);
- if(i&&j)xor_pixel(x+i, y-j, vid);
- if(i&&j)xor_pixel(x-i, y+j, vid);
- }
- }
+ else if(CURRENT_BRUSH==SQUARE_BRUSH)
+ {
+ for(j=0; j<=ry; j++)
+ for(i=0; i<=rx; i++)
+ if(i*j<=ry*rx && ((i+1)>rx || (j+1)>ry))
+ {
+ xor_pixel(x+i, y+j, vid);
+ xor_pixel(x-i, y-j, vid);
+ if(i&&j)xor_pixel(x+i, y-j, vid);
+ if(i&&j)xor_pixel(x-i, y+j, vid);
+ }
+ }
else if(CURRENT_BRUSH==CIRCLE_BRUSH)
for(j=0; j<=ry; j++)
for(i=0; i<=rx; i++)