diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/graphics.c | 26 | ||||
| -rw-r--r-- | src/main.c | 4 | ||||
| -rw-r--r-- | src/powder.c | 215 |
3 files changed, 132 insertions, 113 deletions
diff --git a/src/graphics.c b/src/graphics.c index ffaa333..286182a 100644 --- a/src/graphics.c +++ b/src/graphics.c @@ -1451,13 +1451,13 @@ void draw_parts(pixel *vid) } else { - cr = PIXR(ptypes[t].pcolors); - cg = PIXG(ptypes[t].pcolors); - cb = PIXB(ptypes[t].pcolors); - blendpixel(vid, nx, ny, cr, cg, cb, 255); + 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) + } + else if(cmode==CM_GRAD)//forgot to put else, broke nothing view { float frequency = 0.05; int q = parts[i].temp-40; @@ -2073,7 +2073,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_FILT) { int temp_bin = (int)((parts[i].temp-273.0f)*0.025f); @@ -3160,12 +3160,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) @@ -1249,7 +1249,7 @@ int main(int argc, char *argv[]) if(!sys_pause||framerender) { - update_air(); + update_air(); } #ifdef OpenGL ClearScreen(); @@ -1701,7 +1701,7 @@ int main(int argc, char *argv[]) bsx = 1180; if(bsx<0) bsx = 0; - if(bsy>1180) + if(bsy>1180) bsy = 1180; if(bsy<0) bsy = 0; diff --git a/src/powder.c b/src/powder.c index 89e65fb..2d9a6d0 100644 --- a/src/powder.c +++ b/src/powder.c @@ -556,7 +556,7 @@ inline int create_part(int p, int x, int y, int t) (pmap[y][x]&0xFF)!=PT_BRMT && (pmap[y][x]&0xFF)!=PT_NBLE && (pmap[y][x]&0xFF)!=PT_IRON && - (pmap[y][x]&0xFF)!=PT_INST && + (pmap[y][x]&0xFF)!=PT_INST && (pmap[y][x]&0xFF)!=PT_INWR) return -1; if(parts[pmap[y][x]>>8].life!=0) @@ -599,9 +599,9 @@ inline int create_part(int p, int x, int y, int t) parts[pmap[y][x]>>8].ctype = t; } return -1; - } - if(photons[y][x] && t==PT_PHOT) - return -1; + } + if(photons[y][x] && t==PT_PHOT) + return -1; if(pfree == -1) return -1; i = pfree; @@ -713,115 +713,127 @@ inline int create_part(int p, int x, int y, int t) if(t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP pmap[y][x] = t|(i<<8); if(t==PT_PHOT) - photons[y][x] = t|(i<<8); + photons[y][x] = t|(i<<8); else if(t==PT_STKM) { if(isplayer==0) { - if(pmap[y][x]&0xFF==PT_SPAWN) - { - parts[pmap[y][x]>>8].type = PT_STKM; - parts[pmap[y][x]>>8].vx = 0; - parts[pmap[y][x]>>8].vy = 0; - parts[pmap[y][x]>>8].life = 100; - parts[pmap[y][x]>>8].ctype = 0; - parts[pmap[y][x]>>8].temp = ptypes[t].heat; - - } - else - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_STKM; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 100; - parts[i].ctype = 0; - parts[i].temp = ptypes[t].heat; - } - - - + if(pmap[y][x]&0xFF==PT_SPAWN) + { + parts[pmap[y][x]>>8].type = PT_STKM; + parts[pmap[y][x]>>8].vx = 0; + parts[pmap[y][x]>>8].vy = 0; + parts[pmap[y][x]>>8].life = 100; + parts[pmap[y][x]>>8].ctype = 0; + parts[pmap[y][x]>>8].temp = ptypes[t].heat; + + } + else + { + parts[i].x = (float)x; + parts[i].y = (float)y; + parts[i].type = PT_STKM; + parts[i].vx = 0; + parts[i].vy = 0; + parts[i].life = 100; + parts[i].ctype = 0; + parts[i].temp = ptypes[t].heat; + } + + + player[3] = x-1; //Setting legs positions player[4] = y+6; player[5] = x-1; player[6] = y+6; - + player[7] = x-3; player[8] = y+12; player[9] = x-3; player[10] = y+12; - + player[11] = x+1; player[12] = y+6; player[13] = x+1; player[14] = y+6; - + player[15] = x+3; player[16] = y+12; player[17] = x+3; player[18] = y+12; - + isplayer = 1; } + else + { + return -1; + } //kill_part(playerspawn); create_part(-1,x,y,PT_SPAWN); ISSPAWN1 = 1; } - else if(t==PT_STKM2) + if(t==PT_STKM2) { if(isplayer2==0) { - if(pmap[y][x]&0xFF==PT_SPAWN2) - { - parts[pmap[y][x]>>8].type = PT_STKM2; - parts[pmap[y][x]>>8].vx = 0; - parts[pmap[y][x]>>8].vy = 0; - parts[pmap[y][x]>>8].life = 100; - parts[pmap[y][x]>>8].ctype = 0; - parts[pmap[y][x]>>8].temp = ptypes[t].heat; - - } - else - { - parts[i].x = (float)x; - parts[i].y = (float)y; - parts[i].type = PT_STKM2; - parts[i].vx = 0; - parts[i].vy = 0; - parts[i].life = 100; - parts[i].ctype = 0; - parts[i].temp = ptypes[t].heat; - } - - - + if(pmap[y][x]&0xFF==PT_SPAWN2) + { + parts[pmap[y][x]>>8].type = PT_STKM2; + parts[pmap[y][x]>>8].vx = 0; + parts[pmap[y][x]>>8].vy = 0; + parts[pmap[y][x]>>8].life = 100; + parts[pmap[y][x]>>8].ctype = 0; + parts[pmap[y][x]>>8].temp = ptypes[t].heat; + + } + else + { + parts[i].x = (float)x; + parts[i].y = (float)y; + parts[i].type = PT_STKM2; + parts[i].vx = 0; + parts[i].vy = 0; + parts[i].life = 100; + parts[i].ctype = 0; + parts[i].temp = ptypes[t].heat; + } + + + player2[3] = x-1; //Setting legs positions player2[4] = y+6; player2[5] = x-1; player2[6] = y+6; - + player2[7] = x-3; player2[8] = y+12; player2[9] = x-3; player2[10] = y+12; - + player2[11] = x+1; player2[12] = y+6; player2[13] = x+1; player2[14] = y+6; - + player2[15] = x+3; player2[16] = y+12; player2[17] = x+3; player2[18] = y+12; - + isplayer2 = 1; } + else + { + return -1; + } //kill_part(player2spawn); create_part(-1,x,y,PT_SPAWN2); ISSPAWN2 = 1; } + if(t==PT_BIZR||t==PT_BIZRG) + parts[i].ctype = 0x47FFFF; + if(t!=PT_STKM&&t!=PT_STKM2 && t!=PT_PHOT)// && t!=PT_NEUT) is this needed? it breaks floodfill, Yes photons should not be placed in the PMAP + pmap[y][x] = t|(i<<8); return i; } @@ -1628,10 +1640,10 @@ void update_particles_i(pixel *vid, int start, int inc) if(t==PT_GAS && pv[y/CELL][x/CELL]<-6.0f) t = parts[i].type = PT_OIL; if(t==PT_DESL && pv[y/CELL][x/CELL]>5.0f) - { // Only way I know to make it - t = parts[i].type = PT_FIRE; // combust under pressure. - parts[i].life = rand()%50+120; - } + { + t = parts[i].type = PT_FIRE; + parts[i].life = rand()%50+120; + } if(t==PT_GAS && pv[y/CELL][x/CELL]>6.0f) t = parts[i].type = PT_OIL; if(t==PT_BMTL && pv[y/CELL][x/CELL]>2.5f) @@ -1640,21 +1652,21 @@ void update_particles_i(pixel *vid, int start, int inc) t = parts[i].type = PT_BRMT; if(t==PT_BRCK && pv[y/CELL][x/CELL]>8.8f) t = parts[i].type = PT_STNE; - if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f) + if(t==PT_PIPE && pv[y/CELL][x/CELL]>10.0f) t = parts[i].type = PT_BRMT; - if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f) + if(t==PT_PSTE && pv[y/CELL][x/CELL]>0.5f) t = parts[i].type = PT_PSTS; - if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f) + if(t==PT_PSTS && pv[y/CELL][x/CELL]<0.5f) t = parts[i].type = PT_PSTE; - if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f) + if(t==PT_SHLD1 && pv[y/CELL][x/CELL]>7.0f) t = parts[i].type = PT_NONE; - if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f) + if(t==PT_SHLD2 && pv[y/CELL][x/CELL]>15.0f) t = parts[i].type = PT_NONE; - if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f) + if(t==PT_SHLD3 && pv[y/CELL][x/CELL]>25.0f) t = parts[i].type = PT_NONE; - if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f) + if(t==PT_SHLD4 && pv[y/CELL][x/CELL]>40.0f) t = parts[i].type = PT_NONE; - if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f) + if(t==PT_WIFI && pv[y/CELL][x/CELL]>15.0f) t = parts[i].type = PT_BRMT; //if(t==PT_GLAS && pv[y/CELL][x/CELL]>4.0f) // t = parts[i].type = PT_BGLA; @@ -1667,7 +1679,7 @@ void update_particles_i(pixel *vid, int start, int inc) parts[i].type = PT_BGLA; } } - if(t==PT_QRTZ) + if(t==PT_QRTZ) { parts[i].pavg[0] = parts[i].pavg[1]; parts[i].pavg[1] = pv[y/CELL][x/CELL]; @@ -1683,20 +1695,20 @@ void update_particles_i(pixel *vid, int start, int inc) t = PT_NEUT; create_part(i, x, y, t); } - if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) + if((t==PT_ISOZ||t==PT_ISZS) && 1>rand()%200 && ((int)(-4.0f*(pv[y/CELL][x/CELL])))>(rand()%1000)) { t = PT_PHOT; - rr = (rand()%228+128)/127.0f; - rrr = (rand()%360)*3.14159f/180.0f; - parts[i].life = 680; - parts[i].ctype = 0x3FFFFFFF; - parts[i].vx = rr*cosf(rrr); - parts[i].vy = rr*sinf(rrr); + rr = (rand()%228+128)/127.0f; + rrr = (rand()%360)*3.14159f/180.0f; + parts[i].life = 680; + parts[i].ctype = 0x3FFFFFFF; + parts[i].vx = rr*cosf(rrr); + parts[i].vy = rr*sinf(rrr); create_part(i, x, y, t); } - if(t==PT_PSTE) - if(parts[i].temp>747.0f) - t = parts[i].type = PT_BRCK; + if(t==PT_PSTE) + if(parts[i].temp>747.0f) + t = parts[i].type = PT_BRCK; if(t==PT_SPRK&&parts[i].ctype==PT_ETRD&&parts[i].life==1) { nearp = nearest_part(i, PT_ETRD); @@ -2288,7 +2300,7 @@ void update_particles_i(pixel *vid, int start, int inc) { t = parts[i].type = PT_PLNT; parts[r>>8].type = PT_PLNT; - parts[r>>8].life = 0; + parts[r>>8].life = 0; } else if((r&0xFF)==PT_LAVA && 1>(rand()%250)) { @@ -2514,11 +2526,11 @@ void update_particles_i(pixel *vid, int start, int inc) } else if(((r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && ptypes[parts[r>>8].type].hardness>(rand()%1000))&&parts[i].life>=50) { - if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) - { - parts[i].life--; - parts[r>>8].type = PT_NONE; - } + if(parts_avg(i, r>>8,PT_GLAS)!= PT_GLAS) + { + parts[i].life--; + parts[r>>8].type = PT_NONE; + } } else if (parts[i].life<=50) { @@ -2570,8 +2582,8 @@ void update_particles_i(pixel *vid, int start, int inc) create_n_parts(parts[r>>8].life, x+nx, y+ny, parts[i].vx, parts[i].vy, PT_NEUT); #else create_part(r>>8, x+nx, y+ny, PT_NEUT); - parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; - parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; + parts[r>>8].vx = 0.25f*parts[r>>8].vx + parts[i].vx; + parts[r>>8].vy = 0.25f*parts[r>>8].vy + parts[i].vy; if(parts[r>>8].life>0) { parts[r>>8].life --; @@ -2588,10 +2600,7 @@ void update_particles_i(pixel *vid, int start, int inc) if((r&0xFF)==PT_DYST && 15>(rand()%1000)) parts[r>>8].type = PT_YEST; if((r&0xFF)==PT_YEST) { - if(15>(rand()%100000)&&isplayer==0) - parts[r>>8].type = PT_STKM; - else - parts[r>>8].type = PT_DYST; + parts[r>>8].type = PT_DYST; } if((r&0xFF)==PT_WATR && 15>(rand()%100)) @@ -4115,6 +4124,11 @@ killed: if((parts[i].temp<309.6f) && (parts[i].temp>=243)) parts[i].temp += 1; + if (isplayer) { //Already a stickman in the simulation + death = 1; + parts[i].type = PT_NONE; + } + //Death if(parts[i].life<1 || death == 1 || (pv[y/CELL][x/CELL]>=4.5f && player[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... { @@ -4505,6 +4519,11 @@ killed: if((parts[i].temp<309.6f) && (parts[i].temp>=243)) parts[i].temp += 1; + if (isplayer2) { //Already a stickman2 in the simulation + death2 = 1; + parts[i].type = PT_NONE; + } + //Death if(parts[i].life<1 || death2 == 1 || (pv[y/CELL][x/CELL]>=4.5f && player2[2] != SPC_AIR) ) //If his HP is less that 0 or there is very big wind... { @@ -4516,7 +4535,7 @@ killed: create_part(-1, x+2, y+r, player2[2]); } kill_part(i); //Kill him - goto killed; + continue; } parts[i].vy += -0.7*dt; //Head up! |
