summaryrefslogtreecommitdiff
path: root/src/simulation/elements/REPL.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-05-07 16:59:50 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-05-07 16:59:50 (GMT)
commit51b17badf4c72270bb762ea795d05d51c8b355e3 (patch)
treeb66671e0496b68114c6e91eedb58bf783d5343c0 /src/simulation/elements/REPL.cpp
parentfb111f42d00dd8a2041bae970c0913e096ac5101 (diff)
downloadpowder-51b17badf4c72270bb762ea795d05d51c8b355e3.zip
powder-51b17badf4c72270bb762ea795d05d51c8b355e3.tar.gz
A bit of refactoring (elements)
Diffstat (limited to 'src/simulation/elements/REPL.cpp')
-rw-r--r--src/simulation/elements/REPL.cpp73
1 files changed, 73 insertions, 0 deletions
diff --git a/src/simulation/elements/REPL.cpp b/src/simulation/elements/REPL.cpp
new file mode 100644
index 0000000..e7eae14
--- /dev/null
+++ b/src/simulation/elements/REPL.cpp
@@ -0,0 +1,73 @@
+#include "simulation/Elements.h"
+//#TPT-Directive ElementClass Element_REPL PT_REPL 160
+Element_REPL::Element_REPL()
+{
+ Identifier = "DEFAULT_PT_REPL";
+ Name = "RPEL";
+ Colour = PIXPACK(0x99CC00);
+ MenuVisible = 1;
+ MenuSection = SC_FORCE;
+ Enabled = 1;
+
+ Advection = 0.0f;
+ AirDrag = 0.00f * CFDS;
+ AirLoss = 0.90f;
+ Loss = 0.00f;
+ Collision = 0.0f;
+ Gravity = 0.0f;
+ Diffusion = 0.00f;
+ HotAir = 0.000f * CFDS;
+ Falldown = 0;
+
+ Flammable = 0;
+ Explosive = 0;
+ Meltable = 0;
+ Hardness = 1;
+
+ Weight = 100;
+
+ Temperature = 20.0f+0.0f +273.15f;
+ HeatConduct = 0;
+ Description = "Repel or attract particles based on temp value.";
+
+ State = ST_NONE;
+ Properties = TYPE_SOLID;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = ITH;
+ HighTemperatureTransition = NT;
+
+ Update = &Element_REPL::update;
+ Graphics = NULL;
+}
+
+//#TPT-Directive ElementHeader Element_REPL static int update(UPDATE_FUNC_ARGS)
+int Element_REPL::update(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 = sim->photons[y+ry][x+rx];
+
+ if (r && !(sim->elements[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;
+}
+
+
+Element_REPL::~Element_REPL() {} \ No newline at end of file