summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon <simon@hardwired.org.uk>2011-03-24 15:47:44 (GMT)
committer Simon <simon@hardwired.org.uk>2011-03-24 15:47:44 (GMT)
commitfe90c86fa1f1365d07dc6eee83b074d08efec05a (patch)
treed544d3d7a4f0060acf94293ab89f7a1e1b3e0551
parentdf005748fccd803bb8229fe70e70b0c75ac73027 (diff)
downloadpowder-fe90c86fa1f1365d07dc6eee83b074d08efec05a.zip
powder-fe90c86fa1f1365d07dc6eee83b074d08efec05a.tar.gz
SING pops when it runs out of life
-rw-r--r--src/elements/sing.c38
-rw-r--r--src/powder.c2
2 files changed, 38 insertions, 2 deletions
diff --git a/src/elements/sing.c b/src/elements/sing.c
index 02f5eaf..4514726 100644
--- a/src/elements/sing.c
+++ b/src/elements/sing.c
@@ -1,7 +1,7 @@
#include <element.h>
int update_SING(UPDATE_FUNC_ARGS) {
- int r, rx, ry;
+ int r, rx, ry, cry, crx, rad, nxi, nxj, nb;
int singularity = -parts[i].life;
if (pv[y/CELL][x/CELL]<singularity)
@@ -22,6 +22,41 @@ int update_SING(UPDATE_FUNC_ARGS) {
if (y+CELL>0)
pv[y/CELL-1][x/CELL-1] += 0.1f*(singularity-pv[y/CELL-1][x/CELL-1]);
}
+ if(parts[i].life<1){
+ //Pop!
+ for(rx=-2; rx<3; rx++){
+ crx = (x/CELL)+rx;
+ for(ry=-2; ry<3; ry++){
+ cry = (y/CELL)+ry;
+ if(cry > 0 && crx > 0 && crx < (XRES/CELL) && cry < (YRES/CELL)){
+ pv[cry][crx] += (float)parts[i].tmp;
+ }
+ }
+ }
+ rad = (parts[i].tmp>255)?255:parts[i].tmp;
+ if(rad>=1){
+ rad = (int)(((float)rad)/8.0f);
+ }
+ if(rad>=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) {
+ if(rand()%2){
+ nb = create_part(-1, x+nxi, y+nxj, PT_PHOT);
+ } else {
+ nb = create_part(-1, x+nxi, y+nxj, PT_NEUT);
+ }
+ if (nb!=-1) {
+ parts[nb].life = rand()%300;
+ parts[nb].temp = MAX_TEMP/2;
+ parts[nb].vx = rand()%10-5;
+ parts[nb].vy = rand()%10-5;
+ }
+ }
+ }
+ kill_part(i);
+ return 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))
@@ -50,6 +85,7 @@ int update_SING(UPDATE_FUNC_ARGS) {
continue;
}
parts[i].life += 3;
+ parts[i].tmp++;
}
parts[i].temp = restrict_flt(parts[r>>8].temp+parts[i].temp, MIN_TEMP, MAX_TEMP);
kill_part(r>>8);
diff --git a/src/powder.c b/src/powder.c
index af59585..23de4ff 100644
--- a/src/powder.c
+++ b/src/powder.c
@@ -1374,7 +1374,7 @@ void update_particles_i(pixel *vid, int start, int inc)
{
if (!(parts[i].life==10&&(t==PT_SWCH||t==PT_LCRY||t==PT_PCLN||t==PT_HSWC||t==PT_PUMP)))
parts[i].life--;
- if (parts[i].life<=0 && !(ptypes[t].properties&PROP_CONDUCTS) && t!=PT_ARAY && t!=PT_FIRW && t!=PT_SWCH && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_SPRK && t!=PT_LAVA && t!=PT_LCRY && t!=PT_QRTZ && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4)
+ if (parts[i].life<=0 && !(ptypes[t].properties&PROP_CONDUCTS) && t!=PT_ARAY && t!=PT_FIRW && t!=PT_SWCH && t!=PT_PCLN && t!=PT_HSWC && t!=PT_PUMP && t!=PT_SPRK && t!=PT_LAVA && t!=PT_LCRY && t!=PT_QRTZ && t!=PT_GLOW && t!= PT_FOG && t!=PT_PIPE && t!=PT_FRZW &&(t!=PT_ICEI&&parts[i].ctype!=PT_FRZW)&&t!=PT_INST && t!=PT_SHLD1&& t!=PT_SHLD2&& t!=PT_SHLD3&& t!=PT_SHLD4 && t!=PT_SING)
{
kill_part(i);
continue;