diff options
| author | Philip <philip@philip-linuxlaptop.(none)> | 2010-11-22 20:36:24 (GMT) |
|---|---|---|
| committer | Philip <philip@philip-linuxlaptop.(none)> | 2010-11-22 20:36:24 (GMT) |
| commit | 60e4c076cbb84c457573417cda5e1659b106bf83 (patch) | |
| tree | 86d07be69293871b861898c604fc16306ee7a520 /src | |
| parent | 3d2292890b2d091ba4e7b2e7c1b24dbc7be4ac2c (diff) | |
| download | powder-60e4c076cbb84c457573417cda5e1659b106bf83.zip powder-60e4c076cbb84c457573417cda5e1659b106bf83.tar.gz | |
floodfill fix, @_@ elements, grav changes color
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 38 | ||||
| -rw-r--r-- | src/main.c | 6 | ||||
| -rw-r--r-- | src/powder.c | 110 |
3 files changed, 120 insertions, 34 deletions
diff --git a/src/graphics.c b/src/graphics.c index 8c873d1..03ff5e9 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1495,15 +1495,30 @@ void draw_parts(pixel *vid) cg = 20; cb = 20; if(parts[i].vx>0) - cr += (parts[i].vx)*60; + { + cr += (parts[i].vx)*GRAV_R; + cg += (parts[i].vx)*GRAV_G; + cb += (parts[i].vx)*GRAV_B; + } if(parts[i].vy>0) - cb += (parts[i].vy)*60; + { + cr += (parts[i].vy)*GRAV_G; + cg += (parts[i].vy)*GRAV_B; + cb += (parts[i].vy)*GRAV_R; + + } if(parts[i].vx<0) - cg -= (parts[i].vx)*60; + { + 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)*30; - cg -= (parts[i].vy)*30; + cr -= (parts[i].vy)*GRAV_R2; + cg -= (parts[i].vy)*GRAV_G2; + cb -= (parts[i].vy)*GRAV_B2; } if(cr>255) cr=255; @@ -2840,13 +2855,22 @@ corrupt: void render_cursor(pixel *vid, int x, int y, int t, float rx, float ry) { - int i,j,c; + int i,j,c; + float temprx, tempry; if(t<PT_NUM||t==SPC_AIR||t==SPC_HEAT||t==SPC_COOL||t==SPC_VACUUM) { + tempry = ry; + temprx = rx; if(rx<=0) + { xor_pixel(x, y, vid); + temprx = 1; + } else if(ry<=0) + { xor_pixel(x, y, vid); + tempry = 1; + } if(rx+ry<=0) xor_pixel(x, y, vid); else if(CURRENT_BRUSH==SQUARE_BRUSH) @@ -2864,7 +2888,7 @@ void render_cursor(pixel *vid, int x, int y, int t, float rx, float ry) else if(CURRENT_BRUSH==CIRCLE_BRUSH) for(j=0; j<=ry; j++) for(i=0; i<=rx; i++) - if((i*i)/(rx*rx)+(j*j)/(ry*ry)<=1 && (((i+1)*(i+1))/(rx*rx)+(j*j)/(ry*ry)>1 || ((i*i)/(rx*rx)+((j+1)*(j+1))/(ry*ry)>1))) + if((i*i)/(temprx*temprx)+(j*j)/(tempry*tempry)<=1 && (((i+1)*(i+1))/(temprx*temprx)+(j*j)/(tempry*tempry)>1 || ((i*i)/(temprx*temprx)+((j+1)*(j+1))/(tempry*tempry)>1))) { xor_pixel(x+i, y+j, vid); if(j) xor_pixel(x+i, y-j, vid); @@ -2160,11 +2160,11 @@ int main(int argc, char *argv[]) { #ifdef BETA if(REPLACE_MODE) - sprintf(uitext, "Cracker's Version %d Parts:%d REPLACE MODE", SAVE_VERSION,NUM_PARTS); + sprintf(uitext, "Cracker's V%d FPS:%d Parts:%d REPLACE MODE", SAVE_VERSION, FPS,NUM_PARTS); else if(sdl_mod&(KMOD_CAPS)) - sprintf(uitext, "Cracker's Version %d Parts:%d CAPS LOCK ON", SAVE_VERSION, NUM_PARTS); + sprintf(uitext, "Cracker's V%d FPS:%d Parts:%d CAPS LOCK ON", SAVE_VERSION, FPS, NUM_PARTS); else - sprintf(uitext, "Cracker's Version %d Parts:%d", SAVE_VERSION, NUM_PARTS); + sprintf(uitext, "Cracker's V%d FPS:%d Parts:%d", SAVE_VERSION, FPS, NUM_PARTS); //printf("%s\n", uitext); #else sprintf(uitext, "Version %d.%d FPS:%d", SAVE_VERSION, MINOR_VERSION, FPS); diff --git a/src/powder.c b/src/powder.c index 773d4fd..dac227f 100644 --- a/src/powder.c +++ b/src/powder.c @@ -852,9 +852,55 @@ void update_particles_i(pixel *vid, int start, int inc) int starti = (start*-1); if(sys_pause&&!framerender) return; - + if(ISGRAV==1) + { + ISGRAV = 0; + GRAV ++; + GRAV_R = 60; + GRAV_G = 0; + GRAV_B = 0; + GRAV_R2 = 30; + GRAV_G2 = 30; + GRAV_B2 = 0; + for(int q = 0;q <= GRAV;q++) + { + if(GRAV_R >0 && GRAV_G==0) + { + GRAV_R--; + GRAV_B++; + } + if(GRAV_B >0 && GRAV_R==0) + { + GRAV_B--; + GRAV_G++; + } + if(GRAV_G >0 && GRAV_B==0) + { + GRAV_G--; + GRAV_R++; + } + if(GRAV_R2 >0 && GRAV_G2==0) + { + GRAV_R2--; + GRAV_B2++; + } + if(GRAV_B2 >0 && GRAV_R2==0) + { + GRAV_B2--; + GRAV_G2++; + } + if(GRAV_G2 >0 && GRAV_B2==0) + { + GRAV_G2--; + GRAV_R2++; + } + } + if(GRAV>180) GRAV = 0; + + } if(ISLOVE==1) { + ISLOVE = 0; for(ny=4;ny<YRES-4;ny++) { for(nx=4;nx<XRES-4;nx++) @@ -1351,7 +1397,8 @@ void update_particles_i(pixel *vid, int start, int inc) else { t = parts[i].type = pstates[t].gas; - pv[y/CELL][x/CELL] += 0.50f; + if(t!=PT_A_AS) + pv[y/CELL][x/CELL] += 0.50f; if(t==PT_FIRE) parts[i].life = rand()%50+120; if(t==PT_HFLM) @@ -2005,6 +2052,8 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(t==PT_LOVE) ISLOVE=1; + else if(t==PT_GRAV) + ISGRAV=1; else if(t==PT_CRAC) { if(pv[y/CELL][x/CELL]<=3&&pv[y/CELL][x/CELL]>=-3) @@ -4231,11 +4280,13 @@ int flood_parts(int x, int y, int c, int cm, int bm) } if(cm==-1) { - if(c==0) + if(c==0) { cm = pmap[y][x]&0xFF; if(!cm) return 0; + if(REPLACE_MODE && cm!=SLALT) + return 0; } else cm = 0; @@ -4293,7 +4344,8 @@ int flood_parts(int x, int y, int c, int cm, int bm) int create_parts(int x, int y, float rx, float ry, int c) { - int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0; //n; + int i, j, f = 0, u, v, oy, ox, b = 0, dw = 0, stemp = 0; + float tempry, temprx; //n; int wall = c - 100; @@ -4303,7 +4355,10 @@ int create_parts(int x, int y, float rx, float ry, int c) { if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM) break; - b = wall; + if(wall == WL_ERASE) + b = 0; + else + b = wall; dw = 1; } } @@ -4358,46 +4413,53 @@ int create_parts(int x, int y, float rx, float ry, int c) } return 1; } + temprx = rx;//fixes windows divided by 0 crashing + tempry = ry; + if(rx == 0) rx = 1; + + if(ry == 0) ry = 1; + if(((sdl_mod & (KMOD_LALT) && sdl_mod & (KMOD_SHIFT))|| sdl_mod & (KMOD_CAPS) )&& !REPLACE_MODE) { - for(j=-ry; j<=ry; j++) - for(i=-rx; i<=rx; i++) + for(j=-tempry; j<=tempry; j++) + for(i=-temprx; i<=temprx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) delete_part(x+i, y+j); return 1; } - if(REPLACE_MODE) - { - for(j=-ry; j<=ry; j++) - for(i=-rx; i<=rx; i++) - if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) - delete_part(x+i, y+j); - if(c==0) - return 1; - } + if(c == SPC_AIR || c == SPC_HEAT || c == SPC_COOL || c == SPC_VACUUM) { - for(j=-ry; j<=ry; j++) - for(i=-rx; i<=rx; i++) + for(j=-tempry; j<=tempry; j++) + for(i=-temprx; i<=temprx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) create_part(-1, x+i, y+j, c); return 1; } - if(c == 0) + if(c == 0 && !REPLACE_MODE) { stemp = SLALT; SLALT = 0; - for(j=-ry; j<=ry; j++) - for(i=-rx; i<=rx; i++) + for(j=-tempry; j<=tempry; j++) + for(i=-temprx; i<=temprx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) delete_part(x+i, y+j); SLALT = stemp; return 1; } - - for(j=-ry; j<=ry; j++) - for(i=-rx; i<=rx; i++) + if(REPLACE_MODE) //&& c!=0) + { + for(j=-tempry; j<=tempry; j++) + for(i=-temprx; i<=temprx; i++) + if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) + delete_part(x+i, y+j); + if(c==0) + return 1; + + } + for(j=-tempry; j<=tempry; j++) + for(i=-temprx; i<=temprx; i++) if((CURRENT_BRUSH==CIRCLE_BRUSH && (i*i)/(rx*rx)+(j*j)/(ry*ry)<=1)||(CURRENT_BRUSH==SQUARE_BRUSH&&i*j<=ry*rx)) if(create_part(-1, x+i, y+j, c)==-1) f = 1; |
