summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2013-05-03 21:33:39 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2013-05-03 21:33:39 (GMT)
commitdd0f5f5efb4f108c2ce329a2ceabc7d8fa2b63f8 (patch)
treea623f7319698766a9b3fd826b16692e015fc672d /src
parent2eaed9c9d478292f18d8a6aea9d2c9c869b26911 (diff)
downloadpowder-dd0f5f5efb4f108c2ce329a2ceabc7d8fa2b63f8.zip
powder-dd0f5f5efb4f108c2ce329a2ceabc7d8fa2b63f8.tar.gz
New element: Tungsten, very high melting point
Diffstat (limited to 'src')
-rw-r--r--src/simulation/elements/SPRK.cpp4
-rw-r--r--src/simulation/elements/TUGN.cpp126
2 files changed, 130 insertions, 0 deletions
diff --git a/src/simulation/elements/SPRK.cpp b/src/simulation/elements/SPRK.cpp
index d441455..5d99b07 100644
--- a/src/simulation/elements/SPRK.cpp
+++ b/src/simulation/elements/SPRK.cpp
@@ -158,6 +158,10 @@ int Element_SPRK::update(UPDATE_FUNC_ARGS)
}
}
break;
+ case PT_TUGN:
+ if(parts[i].temp < 3595.0){
+ parts[i].temp += (rand()%20)-4;
+ }
default:
break;
}
diff --git a/src/simulation/elements/TUGN.cpp b/src/simulation/elements/TUGN.cpp
new file mode 100644
index 0000000..e770478
--- /dev/null
+++ b/src/simulation/elements/TUGN.cpp
@@ -0,0 +1,126 @@
+#include "simulation/Elements.h"
+#include "simulation/Air.h"
+//#TPT-Directive ElementClass Element_TUGN PT_TUGN 171
+Element_TUGN::Element_TUGN()
+{
+ Identifier = "DEFAULT_PT_TUGN";
+ Name = "TUGN";
+ Colour = PIXPACK(0x505050);
+ MenuVisible = 1;
+ MenuSection = SC_SOLIDS;
+ 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 = 1;
+ Hardness = 1;
+
+ Weight = 100;
+
+ Temperature = R_TEMP+0.0f +273.15f;
+ HeatConduct = 251;
+ Description = "Brittle metal with a very high melting point";
+
+ State = ST_SOLID;
+ Properties = TYPE_SOLID|PROP_CONDUCTS|PROP_LIFE_DEC;
+
+ LowPressure = IPL;
+ LowPressureTransition = NT;
+ HighPressure = IPH;
+ HighPressureTransition = NT;
+ LowTemperature = ITL;
+ LowTemperatureTransition = NT;
+ HighTemperature = ITL;
+ HighTemperatureTransition = NT;
+ /*HighTemperature = 3895.0f;
+ HighTemperatureTransition = PT_LAVA;*/
+
+ Update = &Element_TUGN::update;
+ Graphics = &Element_TUGN::graphics;
+
+}
+
+#define MELTING_POINT 3695.0
+
+//#TPT-Directive ElementHeader Element_TUGN static int update(UPDATE_FUNC_ARGS)
+int Element_TUGN::update(UPDATE_FUNC_ARGS)
+{
+ bool splode = false;
+ if(parts[i].temp > 2400.0)
+ {
+ int r, rx, ry, rt;
+ for (rx=-1; rx<2; rx++)
+ for (ry=-1; ry<2; ry++)
+ if (BOUNDS_CHECK && (rx || ry))
+ {
+ r = pmap[y+ry][x+rx];
+ if((r&0xFF) == PT_O2)
+ {
+ splode = true;
+ }
+ }
+ }
+ if((parts[i].temp > MELTING_POINT && !(rand()%20)) || splode)
+ {
+ if(!(rand()%50))
+ {
+ sim->pv[y/CELL][x/CELL] += 50.0f;
+ }
+ else if(!(rand()%100))
+ {
+ sim->part_change_type(i, x, y, PT_FIRE);
+ parts[i].life = rand()%500;
+ return 1;
+ }
+ else
+ {
+ sim->part_change_type(i, x, y, PT_LAVA);
+ parts[i].ctype = PT_TUGN;
+ return 1;
+ }
+ if(splode)
+ {
+ parts[i].temp = MELTING_POINT + (rand()%600) + 200;
+ }
+ parts[i].vx += (rand()%100)-50;
+ parts[i].vy += (rand()%100)-50;
+ return 1;
+ }
+ return 0;
+}
+
+
+//#TPT-Directive ElementHeader Element_TUGN static int graphics(GRAPHICS_FUNC_ARGS)
+int Element_TUGN::graphics(GRAPHICS_FUNC_ARGS)
+{
+ double startTemp = (MELTING_POINT - 1500.0);
+ double tempOver = (((cpart->temp - startTemp)/1500.0)*M_PI) - (M_PI/2.0);
+ if(tempOver > -(M_PI/2.0))
+ {
+ if(tempOver > (M_PI/2.0))
+ tempOver = (M_PI/2.0);
+ double gradv = sin(tempOver) + 1.0;
+ *firer = (int)(gradv * 258.0);
+ *fireg = (int)(gradv * 156.0);
+ *fireb = (int)(gradv * 112.0);
+ *firea = 30;
+
+ *colr += *firer;
+ *colg += *fireg;
+ *colb += *fireb;
+ *pixel_mode |= FIRE_ADD;
+ }
+ return 0;
+}
+
+Element_TUGN::~Element_TUGN() {}