diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-25 10:31:21 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2011-10-25 10:31:21 (GMT) |
| commit | 07a1f21df484a252d54c82262ade6d4117425694 (patch) | |
| tree | 80df86661553807159f7fda3fbf2506d5df3b5fa /src/elements/sprk.c | |
| parent | f01056ee0249ad01ed24824aea39f05083110cd6 (diff) | |
| parent | f8d54e66dba5d8448d30f61f84883b4e7e6e1087 (diff) | |
| download | powder-07a1f21df484a252d54c82262ade6d4117425694.zip powder-07a1f21df484a252d54c82262ade6d4117425694.tar.gz | |
Merge latest with graphicstest
Diffstat (limited to 'src/elements/sprk.c')
| -rw-r--r-- | src/elements/sprk.c | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/elements/sprk.c b/src/elements/sprk.c index 2385e26..fdbdb2d 100644 --- a/src/elements/sprk.c +++ b/src/elements/sprk.c @@ -32,7 +32,7 @@ int update_SPRK(UPDATE_FUNC_ARGS) { } else if (ct==PT_ETRD&&parts[i].life==1) { - nearp = nearest_part(i, PT_ETRD); + nearp = nearest_part(i, PT_ETRD, -1); if (nearp!=-1&&parts_avg(i, nearp, PT_INSL)!=PT_INSL) { create_line(x, y, (int)(parts[nearp].x+0.5f), (int)(parts[nearp].y+0.5f), 0, 0, PT_PLSM, 0); @@ -52,6 +52,42 @@ int update_SPRK(UPDATE_FUNC_ARGS) { parts[i].temp = 3500; pv[y/CELL][x/CELL] += 1; } + else if (ct==PT_TESC) // tesla coil code + { + if (parts[i].tmp>300) + parts[i].tmp=300; + 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)) + { + r = pmap[y+ry][x+rx]; + if (r) + continue; + if (rand()%(parts[i].tmp*parts[i].tmp/20+6)==0) + { + int p=create_part(-1, x+rx*2, y+ry*2, PT_LIGH); + if (p!=-1) + { + if(parts[i].tmp<=4) //Prevent Arithmetic errors with zero values + continue; + parts[p].life=rand()%(2+parts[i].tmp/15)+parts[i].tmp/7; + if (parts[i].life>60) + parts[i].life=60; + parts[p].temp=parts[p].life*parts[i].tmp/2.5; + parts[p].tmp2=1; + parts[p].tmp=acos(1.0*rx/sqrt(rx*rx+ry*ry))/M_PI*360; + parts[i].temp-=parts[i].tmp*2+parts[i].temp/5; // slight self-cooling + if (fabs(pv[y/CELL][x/CELL])!=0.0f) + { + if (fabs(pv[y/CELL][x/CELL])<=0.5f) + pv[y/CELL][x/CELL]=0; + else + pv[y/CELL][x/CELL]-=(pv[y/CELL][x/CELL]>0)?0.5:-0.5; + } + } + } + } + } else if (ct==PT_IRON) { for (rx=-1; rx<2; rx++) for (ry=-1; ry<2; ry++) |
