diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-08 17:39:03 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-08 17:39:03 (GMT) |
| commit | b0ea52690ba56a0d0602ad8674b7e5ab2ba3e778 (patch) | |
| tree | 7d72e0509f4d2643d3be837a337d088ca5949c73 /elements/elec.cpp | |
| download | powder-b0ea52690ba56a0d0602ad8674b7e5ab2ba3e778.zip powder-b0ea52690ba56a0d0602ad8674b7e5ab2ba3e778.tar.gz | |
Initial
Diffstat (limited to 'elements/elec.cpp')
| -rw-r--r-- | elements/elec.cpp | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/elements/elec.cpp b/elements/elec.cpp new file mode 100644 index 0000000..6b06f8f --- /dev/null +++ b/elements/elec.cpp @@ -0,0 +1,101 @@ +#include "element.h" + +int update_ELEC(UPDATE_FUNC_ARGS) { + int r, rt, rx, ry, nb, rrx, rry; + float rr, rrr; + parts[i].pavg[0] = x; + parts[i].pavg[1] = y; + if(pmap[y][x]==PT_GLOW) + { + sim->part_change_type(i, x, y, PT_PHOT); + } + for (rx=-2; rx<=2; rx++) + for (ry=-2; ry<=2; ry++) + if (x+rx>=0 && y+ry>=0 && x+rx<XRES && y+ry<YRES) { + r = pmap[y+ry][x+rx]; + if (!r) + r = sim->photons[y+ry][x+rx]; + if (!r) + continue; + if ((r&0xFF)==PT_GLAS) + { + //fire_r[y/CELL][x/CELL] += rand()%200; //D: Doesn't work with OpenGL, also shouldn't be here TODO: FIX THIS SHIT + //fire_g[y/CELL][x/CELL] += rand()%200; + //fire_b[y/CELL][x/CELL] += rand()%200; + for (rrx=-1; rrx<=1; rrx++) + { + for (rry=-1; rry<=1; rry++) + { + if (x+rx+rrx>=0 && y+ry+rry>=0 && x+rx+rrx<XRES && y+ry+rry<YRES) { + nb = sim->create_part(-1, x+rx+rrx, y+ry+rry, PT_BOMB); + if (nb!=-1) { + parts[nb].tmp = 1; + parts[nb].life = 50; + parts[nb].temp = 400.0f; + parts[nb].vx = rand()%20-10; + parts[nb].vy = rand()%20-10; + } + } + } + } + sim->kill_part(i); + return 1; + } + if ((r&0xFF)==PT_LCRY) + { + parts[r>>8].tmp2 = 5+rand()%5; + } + if ((r&0xFF)==PT_WATR || (r&0xFF)==PT_DSTW || (r&0xFF)==PT_SLTW || (r&0xFF)==PT_CBNW) + { + if(rand()%2) + { + sim->create_part(r>>8, x+rx, y+ry, PT_H2); + sim->part_change_type(i, x, y, PT_O2); + parts[i].life = 0; + parts[i].ctype = 0; + return 1; + } + else + { + sim->create_part(r>>8, x+rx, y+ry, PT_O2); + sim->part_change_type(i, x, y, PT_H2); + parts[i].life = 0; + parts[i].ctype = 0; + return 1; + } + } + if ((r&0xFF)==PT_NEUT) + { + sim->part_change_type(r>>8, x+rx, y+ry, PT_H2); + parts[r>>8].life = 0; + parts[r>>8].ctype = 0; + } + if ((r&0xFF)==PT_DEUT) + { + if(parts[r>>8].life < 6000) + parts[r>>8].life += 1; + parts[r>>8].temp = 0; + parts[i].temp = 0; + sim->kill_part(i); + return 1; + } + if (sim->ptypes[r&0xFF].properties & PROP_CONDUCTS) + { + sim->create_part(-1, x+rx, y+ry, PT_SPRK); + sim->kill_part(i); + return 1; + } + } + return 0; +} + +int graphics_ELEC(GRAPHICS_FUNC_ARGS) +{ + *firea = 70; + *firer = *colr; + *fireg = *colg; + *fireb = *colb; + + *pixel_mode |= FIRE_ADD; + return 0; +} |
