From 25b95e211e5c38e29798bfb6be9c5656d9a408d7 Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 29 Dec 2010 09:44:12 -0500 Subject: [PATCH 1/2] new display, Life, shows life in a grayscale gradient, will ONLY show up in debug mode, on shift-1, fix filt floodfill, portal has bigger storage, other fixes. --- includes/powder.h | 9 +++++---- src/graphics.c | 34 ++++++++++++++++++++++++++++++++-- src/interface.c | 8 ++++++++ src/main.c | 36 +++++++++++++++++++++++++++++++----- src/powder.c | 5 +++-- 5 files changed, 79 insertions(+), 13 deletions(-) diff --git a/includes/powder.h b/includes/powder.h index 45e818139..76ed40aba 100644 --- a/includes/powder.h +++ b/includes/powder.h @@ -5,8 +5,9 @@ #include "defines.h" #include "interface.h" -#define CM_COUNT 10 -#define CM_CRACK 9 +#define CM_COUNT 11 +#define CM_CRACK 10 +#define CM_LIFE 9 #define CM_GRAD 8 #define CM_NOTHING 7 #define CM_FANCY 6 @@ -582,8 +583,8 @@ static int lolzrule[9][9] = {0,1,0,0,0,0,0,1,0}, {0,1,0,0,0,0,0,1,0}, }; -int portal[MAX_TEMP/100][8][8]; -float portaltemp[MAX_TEMP/100][8][8]; +int portal[MAX_TEMP/100][8][80]; +float portaltemp[MAX_TEMP/100][8][80]; int wireless[MAX_TEMP/100][2]; extern int isplayer; diff --git a/src/graphics.c b/src/graphics.c index a2e73e61a..a22cf5804 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1478,6 +1478,31 @@ void draw_parts(pixel *vid) cb = 0; blendpixel(vid, nx, ny, cr, cg, cb, 255); } + else if(cmode==CM_LIFE) + { + float frequency = 0.4; + int q; + if(!(parts[i].life<5)) + q = sqrt(parts[i].life); + else + q = parts[i].life; + cr = sin(frequency*q) * 100 + 128; + cg = sin(frequency*q) * 100 + 128; + cb = sin(frequency*q) * 100 + 128; + 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++) @@ -2400,7 +2425,8 @@ void draw_parts(pixel *vid) blendpixel(vid, nx-1, ny-1, cr, cg, cb, 32); } } - else if(t==PT_BOMB){ + else if(t==PT_BOMB) + { if(parts[i].tmp==0){ cr = PIXR(ptypes[t].pcolors); cg = PIXG(ptypes[t].pcolors); @@ -2425,6 +2451,8 @@ void draw_parts(pixel *vid) addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); gradv = gradv/1.1f; } + } else { + blendpixel(vid, nx, ny, cr, cg, cb, 255); } } else if(parts[i].tmp==1){ @@ -2442,6 +2470,8 @@ void draw_parts(pixel *vid) addpixel(vid, nx, ny-newx, cr, cg, cb, gradv); gradv = gradv/1.5f; } + } else { + blendpixel(vid, nx, ny, cr, cg, cb, 255); } } else { @@ -3318,7 +3348,7 @@ void sdl_open(void) SDL_WM_SetCaption("The Powder Toy", "Powder Toy"); sdl_seticon(); SDL_EnableUNICODE(1); - //SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); + SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL); } #ifdef OpenGL diff --git a/src/interface.c b/src/interface.c index f58b2a4d2..fef6445a3 100644 --- a/src/interface.c +++ b/src/interface.c @@ -562,6 +562,9 @@ void draw_svf_ui(pixel *vid_buf) case CM_GRAD: drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\xD3", 255, 50, 255, 255); break; + case CM_LIFE: + drawtext(vid_buf, XRES-29+BARSIZE/*481*/, YRES+(MENUSIZE-13), "\x00", 255, 50, 255, 255); + break; } drawrect(vid_buf, XRES-32+BARSIZE/*478*/, YRES+(MENUSIZE-16), 14, 14, 255, 255, 255, 255); @@ -1857,6 +1860,11 @@ void set_cmode(int cm) strcpy(itc_msg, "Alternate Velocity Display"); else if(cmode==CM_GRAD) strcpy(itc_msg, "Heat Gradient Display"); + else if(cmode==CM_LIFE) + if(DEBUG_MODE) + strcpy(itc_msg, "Life Display"); + else + set_cmode(CM_CRACK); else strcpy(itc_msg, "Velocity Display"); } diff --git a/src/main.c b/src/main.c index 050469d2c..42a3d75de 100644 --- a/src/main.c +++ b/src/main.c @@ -1357,7 +1357,7 @@ int main(int argc, char *argv[]) free(load_data); } } - if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL))) + if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !player2)) { if(it > 50) it = 50; @@ -1403,6 +1403,10 @@ int main(int argc, char *argv[]) { set_cmode(CM_CRACK); } + if(sdl_key=='1'&& (sdl_mod & (KMOD_SHIFT)) && DEBUG_MODE) + { + set_cmode(CM_LIFE); + } if(sdl_key==SDLK_TAB) { CURRENT_BRUSH =(CURRENT_BRUSH + 1)%BRUSH_NUM ; @@ -1487,7 +1491,7 @@ int main(int argc, char *argv[]) bsy = 0; } } - if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL))) + if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !player2)) DEBUG_MODE = !DEBUG_MODE; if(sdl_key=='i') { @@ -1586,10 +1590,32 @@ int main(int argc, char *argv[]) } } #ifdef INTERNAL + int counterthing; if(sdl_key=='v') - vs = !vs; + { + if(sdl_mod & (KMOD_SHIFT)){ + if(vs>=1) + vs = 0; + else + vs = 2; + } + else{ + if(vs>=1) + vs = 0; + else + vs = 1; + } + counterthing = 0; + } if(vs) - dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE); + { + if(counterthing+1>=vs) + { + dump_frame(vid_buf, XRES, YRES, XRES+BARSIZE); + counterthing = 0; + } + counterthing = (counterthing+1)%3; + } #endif if(sdl_wheel) @@ -2122,7 +2148,7 @@ int main(int argc, char *argv[]) { if(sdl_mod & (KMOD_CAPS)) c = 0; - if(c!=WL_STREAM&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE) + if(c!=WL_STREAM+100&&c!=SPC_AIR&&c!=SPC_HEAT&&c!=SPC_COOL&&c!=SPC_VACUUM&&!REPLACE_MODE) flood_parts(x, y, c, -1, -1); lx = x; ly = y; diff --git a/src/powder.c b/src/powder.c index 2c7944e5c..8e7a4ea08 100644 --- a/src/powder.c +++ b/src/powder.c @@ -986,6 +986,7 @@ inline int parts_avg(int ci, int ni,int t) else return PT_NONE; } + return PT_NONE; } @@ -3165,7 +3166,7 @@ void update_particles_i(pixel *vid, int start, int inc) if((r>>8)>=NPART || !r) continue; if(parts[r>>8].type==PT_SPRK || (parts[r>>8].type!=PT_PRTI && parts[r>>8].type!=PT_PRTO && (ptypes[parts[r>>8].type].falldown!= 0 || pstates[parts[r>>8].type].state == ST_GAS))) - for( nnx=0;nnx<8;nnx++) + for( nnx=0;nnx<80;nnx++) if(!portal[parts[i].tmp][count-1][nnx]) { portal[parts[i].tmp][count-1][nnx] = parts[r>>8].type; @@ -3196,7 +3197,7 @@ void update_particles_i(pixel *vid, int start, int inc) continue; if(!r) { - for( nnx =0 ;nnx<8;nnx++) + for( nnx =0 ;nnx<80;nnx++) { int randomness = count + rand()%3-1; if(randomness<1) From 5766f9aa7ee0f78adea5799322dce67506d9247d Mon Sep 17 00:00:00 2001 From: Cracker64 Date: Wed, 29 Dec 2010 14:35:38 -0500 Subject: [PATCH 2/2] 'd' and 's' will work normally if there is no stickman, otherwise shift-d and shift-s, corrected silly mistake --- src/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.c b/src/main.c index 42a3d75de..8a0cf0e51 100644 --- a/src/main.c +++ b/src/main.c @@ -1357,7 +1357,7 @@ int main(int argc, char *argv[]) free(load_data); } } - if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !player2)) + if(sdl_key=='s' && (sdl_mod & (KMOD_CTRL)) || (sdl_key=='s' && !isplayer2)) { if(it > 50) it = 50; @@ -1491,7 +1491,7 @@ int main(int argc, char *argv[]) bsy = 0; } } - if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !player2)) + if(sdl_key=='d'&&(sdl_mod & (KMOD_CTRL)) || (sdl_key=='d' && !isplayer2)) DEBUG_MODE = !DEBUG_MODE; if(sdl_key=='i') {