diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-25 16:11:36 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-07-25 16:11:36 (GMT) |
| commit | 0afecb5b77442d770f5ebb149f574d87859ebde7 (patch) | |
| tree | eb7680b00904bae0fe2382245cb2197da5cb7ab5 /src/simulation/elements/BOMB.cpp | |
| parent | 57c356e495f30c01a08bbd5d00b923f51badac9d (diff) | |
| download | powder-0afecb5b77442d770f5ebb149f574d87859ebde7.zip powder-0afecb5b77442d770f5ebb149f574d87859ebde7.tar.gz | |
TPT: Replace all explosion sparks with new element (EMBR) 1d5b081942
Diffstat (limited to 'src/simulation/elements/BOMB.cpp')
| -rw-r--r-- | src/simulation/elements/BOMB.cpp | 115 |
1 files changed, 44 insertions, 71 deletions
diff --git a/src/simulation/elements/BOMB.cpp b/src/simulation/elements/BOMB.cpp index ccf56bd..b170cc2 100644 --- a/src/simulation/elements/BOMB.cpp +++ b/src/simulation/elements/BOMB.cpp @@ -50,65 +50,53 @@ Element_BOMB::Element_BOMB() int Element_BOMB::update(UPDATE_FUNC_ARGS) { int r, rx, ry, nb; - //Spark is used so much now that it should be a seperate element. - if (parts[i].tmp==1) { - for (rx=-1; rx<2; rx++) - for (ry=-1; ry<2; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) + + for (rx=-2; rx<3; rx++) + for (ry=-2; ry<3; ry++) + if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) + { + r = pmap[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_EMBR && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((sim->elements[r&0xFF].Properties & (TYPE_SOLID | TYPE_PART | TYPE_LIQUID)) && !(sim->elements[r&0xFF].Properties & PROP_SPARKSETTLE)) { - sim->kill_part(i); - return 1; - } - } - } else if (parts[i].tmp==0) { - for (rx=-2; rx<3; rx++) - for (ry=-2; ry<3; ry++) - if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry)) - { - r = pmap[y+ry][x+rx]; - if (!r) - continue; - if ((r&0xFF)!=PT_BOMB && (r&0xFF)!=PT_DMND && (r&0xFF)!=PT_CLNE && (r&0xFF)!=PT_PCLN && (r&0xFF)!=PT_BCLN) { - int rad = 8; - int nxi; - int nxj; - pmap[y][x] = 0; - for (nxj=-rad; nxj<=rad; nxj++) - for (nxi=-rad; nxi<=rad; nxi++) - if ((pow((float)nxi,2))/(pow((float)rad,2))+(pow((float)nxj,2))/(pow((float)rad,2))<=1) - if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) { - sim->delete_part(x+nxi, y+nxj, 0);//it SHOULD kill anything but the exceptions above, doesn't seem to always work - sim->pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; - nb = sim->create_part(-1, x+nxi, y+nxj, PT_BOMB); - if (nb!=-1) { - parts[nb].tmp = 2; - parts[nb].life = 2; - parts[nb].temp = MAX_TEMP; - } - } - for (nxj=-(rad+1); nxj<=(rad+1); nxj++) - for (nxi=-(rad+1); nxi<=(rad+1); nxi++) - if ((pow((float)nxi,2))/(pow((float)(rad+1),2))+(pow((float)nxj,2))/(pow((float)(rad+1),2))<=1) { - nb = sim->create_part(-1, x+nxi, y+nxj, PT_BOMB); - if (nb!=-1) { - parts[nb].tmp = 1; - parts[nb].life = 50; + int rad = 8; + int nxi; + int nxj; + pmap[y][x] = 0; + for (nxj=-rad; nxj<=rad; nxj++) + for (nxi=-rad; nxi<=rad; nxi++) + if ((pow(nxi,2))/(pow(rad,2))+(pow(nxj,2))/(pow(rad,2))<=1) + if ((pmap[y+nxj][x+nxi]&0xFF)!=PT_DMND && (pmap[y+nxj][x+nxi]&0xFF)!=PT_CLNE && (pmap[y+nxj][x+nxi]&0xFF)!=PT_PCLN && (pmap[y+nxj][x+nxi]&0xFF)!=PT_BCLN) + { + sim->delete_part(x+nxi, y+nxj, 0); + pv[(y+nxj)/CELL][(x+nxi)/CELL] += 0.1f; + nb = sim->create_part(-3, x+nxi, y+nxj, PT_EMBR); + if (nb!=-1) + { + parts[nb].tmp = 2; + parts[nb].life = 2; parts[nb].temp = MAX_TEMP; - parts[nb].vx = rand()%20-10; - parts[nb].vy = rand()%20-10; } } - //CreateParts(x, y, 9, 9, PT_BOMB); - //CreateParts(x, y, 8, 8, PT_NONE); - sim->kill_part(i); - return 1; - } + for (nxj=-(rad+1); nxj<=(rad+1); nxj++) + for (nxi=-(rad+1); nxi<=(rad+1); nxi++) + if ((pow(nxi,2))/(pow((rad+1),2))+(pow(nxj,2))/(pow((rad+1),2))<=1 && !(pmap[y+nxj][x+nxi]&0xFF)) + { + nb = sim->create_part(-3, x+nxi, y+nxj, PT_EMBR); + if (nb!=-1) + { + parts[nb].tmp = 0; + parts[nb].life = 50; + parts[nb].temp = MAX_TEMP; + parts[nb].vx = rand()%40-20; + parts[nb].vy = rand()%40-20; + } + } + sim->kill_part(i); + return 1; } - } + } return 0; } @@ -117,23 +105,8 @@ int Element_BOMB::update(UPDATE_FUNC_ARGS) int Element_BOMB::graphics(GRAPHICS_FUNC_ARGS) { - if (cpart->tmp==0) { - //Normal bomb - *pixel_mode |= PMODE_FLARE; - } - else if(cpart->tmp==2) - { - //Flash - *pixel_mode = PMODE_FLAT | FIRE_ADD; - *colr = *colg = *colb = *firer = *fireg = *fireb = *firea = 255; - } - else - { - //Flying spark - *pixel_mode = PMODE_SPARK | PMODE_ADD; - *cola = 4*cpart->life; - } - return 0; + *pixel_mode |= PMODE_FLARE; + return 1; } |
