summaryrefslogtreecommitdiff
path: root/src/elements
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-02-25 10:26:02 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-02-25 10:26:02 (GMT)
commitf6696282e1d06081bb8b9d7a394483562b9f2165 (patch)
treee79cb452dc15bb2264cd1044ba56e9f916e4305e /src/elements
parent1c4bce1f22d67c25b9bf7ec92dbef37628885f1e (diff)
downloadpowder-f6696282e1d06081bb8b9d7a394483562b9f2165.zip
powder-f6696282e1d06081bb8b9d7a394483562b9f2165.tar.gz
Added FRAY - Force-ray and RPEL - Repeller
Diffstat (limited to 'src/elements')
-rw-r--r--src/elements/fray.c29
-rw-r--r--src/elements/repl.c22
2 files changed, 51 insertions, 0 deletions
diff --git a/src/elements/fray.c b/src/elements/fray.c
new file mode 100644
index 0000000..1b8cc9b
--- /dev/null
+++ b/src/elements/fray.c
@@ -0,0 +1,29 @@
+#include <element.h>
+
+int update_FRAY(UPDATE_FUNC_ARGS) {
+ int r, nxx, nyy, docontinue, len, nxi, nyi, rx, ry, nr, ry1, rx1;
+ 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 ((r&0xFF)==PT_SPRK) {
+ for (docontinue = 1, nxx = 0, nyy = 0, nxi = rx*-1, nyi = ry*-1, len = 0; docontinue; nyy+=nyi, nxx+=nxi, len++) {
+ if (!(x+nxi+nxx<XRES && y+nyi+nyy<YRES && x+nxi+nxx >= 0 && y+nyi+nyy >= 0) || len>10) {
+ break;
+ }
+ r = pmap[y+nyi+nyy][x+nxi+nxx];
+ if (!r)
+ r = photons[y+nyi+nyy][x+nxi+nxx];
+
+ if (r && !(ptypes[r&0xFF].properties & TYPE_SOLID)){
+ parts[r>>8].vx += nxi*((parts[i].temp-273.15)/10.0f);
+ parts[r>>8].vy += nyi*((parts[i].temp-273.15)/10.0f);
+ }
+ }
+ }
+ }
+ return 0;
+}
diff --git a/src/elements/repl.c b/src/elements/repl.c
new file mode 100644
index 0000000..254e219
--- /dev/null
+++ b/src/elements/repl.c
@@ -0,0 +1,22 @@
+#include <element.h>
+
+int update_REPL(UPDATE_FUNC_ARGS) {
+ int r, rx, ry, ri;
+ for(ri = 0; ri <= 10; ri++)
+ {
+ rx = (rand()%20)-10;
+ ry = (rand()%20)-10;
+ if (x+rx>=0 && y+ry>0 && x+rx<XRES && y+ry<YRES && (rx || ry))
+ {
+ r = pmap[y+ry][x+rx];
+ if (!r)
+ r = photons[y+ry][x+rx];
+
+ if (r && !(ptypes[r&0xFF].properties & TYPE_SOLID)){
+ parts[r>>8].vx += isign(rx)*((parts[i].temp-273.15)/10.0f);
+ parts[r>>8].vy += isign(ry)*((parts[i].temp-273.15)/10.0f);
+ }
+ }
+ }
+ return 0;
+}