diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-11-17 19:44:09 (GMT) |
| commit | 058a2edd75debbd0297f92572316daa704bd379f (patch) | |
| tree | ad303f091f9a08b209b91eb34a9fcad996a3de69 /src/simulation/tools | |
| parent | e3594aba9e05c6865d396418c028049cda92c2f3 (diff) | |
| parent | 7a21ae192fe19868539956f3fe28e62b2c7c4429 (diff) | |
| download | powder-058a2edd75debbd0297f92572316daa704bd379f.zip powder-058a2edd75debbd0297f92572316daa704bd379f.tar.gz | |
Merge branch 'master' of github.com:FacialTurd/PowderToypp
Diffstat (limited to 'src/simulation/tools')
| -rw-r--r-- | src/simulation/tools/AirTool.cpp | 22 | ||||
| -rw-r--r-- | src/simulation/tools/Cool.cpp | 23 | ||||
| -rw-r--r-- | src/simulation/tools/GravTool.cpp | 18 | ||||
| -rw-r--r-- | src/simulation/tools/Heat.cpp | 23 | ||||
| -rw-r--r-- | src/simulation/tools/NGrv.cpp | 18 | ||||
| -rw-r--r-- | src/simulation/tools/SimTool.cpp | 10 | ||||
| -rw-r--r-- | src/simulation/tools/SimTool.h | 23 | ||||
| -rw-r--r-- | src/simulation/tools/Vac.cpp | 22 |
8 files changed, 159 insertions, 0 deletions
diff --git a/src/simulation/tools/AirTool.cpp b/src/simulation/tools/AirTool.cpp new file mode 100644 index 0000000..9fd7f79 --- /dev/null +++ b/src/simulation/tools/AirTool.cpp @@ -0,0 +1,22 @@ +#include "simulation/Tools.h" +#include "simulation/Air.h" +//#TPT-Directive ToolClass Tool_Air TOOL_AIR 3 +Tool_Air::Tool_Air() +{ + Identifier = "DEFAULT_TOOL_AIR"; + Name = "AIR"; + Colour = PIXPACK(0xFFFFFF); + Description = "Creates air pressure"; +} + +int Tool_Air::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->air->pv[y/CELL][x/CELL] += 0.03f*strength; + if(sim->air->pv[y/CELL][x/CELL] > 256.0f) + sim->air->pv[y/CELL][x/CELL] = 256.0f; + if(sim->air->pv[y/CELL][x/CELL] < -256.0f) + sim->air->pv[y/CELL][x/CELL] = -256.0f; + return 1; +} + +Tool_Air::~Tool_Air() {}
\ No newline at end of file diff --git a/src/simulation/tools/Cool.cpp b/src/simulation/tools/Cool.cpp new file mode 100644 index 0000000..b1b57b1 --- /dev/null +++ b/src/simulation/tools/Cool.cpp @@ -0,0 +1,23 @@ +#include "simulation/Tools.h" +//#TPT-Directive ToolClass Tool_Cool TOOL_COOL 1 +Tool_Cool::Tool_Cool() +{ + Identifier = "DEFAULT_TOOL_COOL"; + Name = "COOL"; + Colour = PIXPACK(0x00DDFF); + Description = "Cools particles"; +} + +int Tool_Cool::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + if(!cpart) + return 0; + cpart->temp -= strength; + if(cpart->temp > MAX_TEMP) + cpart->temp = MAX_TEMP; + if(cpart->temp < 0) + cpart->temp = 0; + return 1; +} + +Tool_Cool::~Tool_Cool() {}
\ No newline at end of file diff --git a/src/simulation/tools/GravTool.cpp b/src/simulation/tools/GravTool.cpp new file mode 100644 index 0000000..630ba12 --- /dev/null +++ b/src/simulation/tools/GravTool.cpp @@ -0,0 +1,18 @@ +#include "simulation/Tools.h" +#include "simulation/Simulation.h" +//#TPT-Directive ToolClass Tool_Grav TOOL_GRAV 4 +Tool_Grav::Tool_Grav() +{ + Identifier = "DEFAULT_TOOL_GRAV"; + Name = "GRAV"; + Colour = PIXPACK(0xCCCCFF); + Description = "Creates a short-lasting gravity well"; +} + +int Tool_Grav::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] += 0.03f*strength; + return 1; +} + +Tool_Grav::~Tool_Grav() {}
\ No newline at end of file diff --git a/src/simulation/tools/Heat.cpp b/src/simulation/tools/Heat.cpp new file mode 100644 index 0000000..f28274c --- /dev/null +++ b/src/simulation/tools/Heat.cpp @@ -0,0 +1,23 @@ +#include "simulation/Tools.h" +//#TPT-Directive ToolClass Tool_Heat TOOL_HEAT 0 +Tool_Heat::Tool_Heat() +{ + Identifier = "DEFAULT_TOOL_HEAT"; + Name = "HEAT"; + Colour = PIXPACK(0xFFDD00); + Description = "Heats particles"; +} + +int Tool_Heat::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + if(!cpart) + return 0; + cpart->temp += strength; + if(cpart->temp > MAX_TEMP) + cpart->temp = MAX_TEMP; + if(cpart->temp < 0) + cpart->temp = 0; + return 1; +} + +Tool_Heat::~Tool_Heat() {}
\ No newline at end of file diff --git a/src/simulation/tools/NGrv.cpp b/src/simulation/tools/NGrv.cpp new file mode 100644 index 0000000..525d697 --- /dev/null +++ b/src/simulation/tools/NGrv.cpp @@ -0,0 +1,18 @@ +#include "simulation/Tools.h" +#include "simulation/Simulation.h" +//#TPT-Directive ToolClass Tool_NGrv TOOL_NGRV 5 +Tool_NGrv::Tool_NGrv() +{ + Identifier = "DEFAULT_TOOL_NGRV"; + Name = "NGRV"; + Colour = PIXPACK(0xAACCFF); + Description = "Creates a short-lasting negative gravity well"; +} + +int Tool_NGrv::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->gravmap[((y/CELL)*(XRES/CELL))+(x/CELL)] -= 0.03f*strength; + return 1; +} + +Tool_NGrv::~Tool_NGrv() {}
\ No newline at end of file diff --git a/src/simulation/tools/SimTool.cpp b/src/simulation/tools/SimTool.cpp new file mode 100644 index 0000000..d7015fa --- /dev/null +++ b/src/simulation/tools/SimTool.cpp @@ -0,0 +1,10 @@ +#include "simulation/Element.h" +#include "simulation/Tools.h" + +SimTool::SimTool(): +Identifier("DEFAULT_TOOL_INVALID"), +Name(""), +Colour(PIXPACK(0xFFFFFF)), +Description("NULL Tool, does NOTHING") +{ +}
\ No newline at end of file diff --git a/src/simulation/tools/SimTool.h b/src/simulation/tools/SimTool.h new file mode 100644 index 0000000..c32ba5b --- /dev/null +++ b/src/simulation/tools/SimTool.h @@ -0,0 +1,23 @@ +#ifndef SIMTOOL_H +#define SIMTOOL_H + +#include "simulation/Simulation.h" +#include "graphics/Renderer.h" +#include "simulation/Elements.h" + +class Simulation; +struct Particle; +class SimTool +{ +public: + char *Identifier; + char *Name; + pixel Colour; + char *Description; + + SimTool(); + virtual ~SimTool() {} + virtual int Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) { return 0; } +}; + +#endif
\ No newline at end of file diff --git a/src/simulation/tools/Vac.cpp b/src/simulation/tools/Vac.cpp new file mode 100644 index 0000000..aa319e2 --- /dev/null +++ b/src/simulation/tools/Vac.cpp @@ -0,0 +1,22 @@ +#include "simulation/Tools.h" +#include "simulation/Air.h" +//#TPT-Directive ToolClass Tool_Vac TOOL_VAC 2 +Tool_Vac::Tool_Vac() +{ + Identifier = "DEFAULT_TOOL_VAC"; + Name = "VAC"; + Colour = PIXPACK(0x303030); + Description = "Removes air pressure"; +} + +int Tool_Vac::Perform(Simulation * sim, Particle * cpart, int x, int y, float strength) +{ + sim->air->pv[y/CELL][x/CELL] -= 0.03f*strength; + if(sim->air->pv[y/CELL][x/CELL] > 256.0f) + sim->air->pv[y/CELL][x/CELL] = 256.0f; + if(sim->air->pv[y/CELL][x/CELL] < -256.0f) + sim->air->pv[y/CELL][x/CELL] = -256.0f; + return 1; +} + +Tool_Vac::~Tool_Vac() {} |
