diff options
| author | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-14 18:51:24 (GMT) |
|---|---|---|
| committer | Simon Robertshaw <simon@hardwired.org.uk> | 2012-01-14 18:51:24 (GMT) |
| commit | 2c9295007a287dc01ff63fcf7b3da141f7474e37 (patch) | |
| tree | e8065e920ca45686a40e41fd46513e13d46f47b0 /src/interface.old/Sandbox.cpp | |
| parent | fc2f52099c0bbb2412046252bf7b5e4113bbe8e4 (diff) | |
| download | powder-2c9295007a287dc01ff63fcf7b3da141f7474e37.zip powder-2c9295007a287dc01ff63fcf7b3da141f7474e37.tar.gz | |
Various things, also IEF UI
Diffstat (limited to 'src/interface.old/Sandbox.cpp')
| -rw-r--r-- | src/interface.old/Sandbox.cpp | 76 |
1 files changed, 76 insertions, 0 deletions
diff --git a/src/interface.old/Sandbox.cpp b/src/interface.old/Sandbox.cpp new file mode 100644 index 0000000..5e29bae --- /dev/null +++ b/src/interface.old/Sandbox.cpp @@ -0,0 +1,76 @@ +/* + * Sandbox.cpp + * + * Created on: Jan 8, 2012 + * Author: Simon + */ + +#include <iostream> + +#include "Config.h" + +#include "interface/Sandbox.h" +#include "interface/Component.h" +#include "Renderer.h" +#include "Simulation.h" + +namespace ui { + +Sandbox::Sandbox(): + Component(0, 0, XRES, YRES), + ren(NULL), + isMouseDown(false), + activeElement(1) +{ + sim = new Simulation(); +} + +Simulation * Sandbox::GetSimulation() +{ + return sim; +} + +void Sandbox::OnMouseMovedInside(int localx, int localy, int dx, int dy) +{ + if(isMouseDown) + { + sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0); + lastCoordX = localx; + lastCoordY = localy; + } +} + +void Sandbox::OnMouseDown(int localx, int localy, unsigned int button) +{ + sim->create_line(localx, localy, localx, localy, 2, 2, activeElement, 0); + lastCoordX = localx; + lastCoordY = localy; + isMouseDown = true; +} + +void Sandbox::OnMouseUp(int localx, int localy, unsigned int button) +{ + sim->create_line(lastCoordX, lastCoordY, localx, localy, 2, 2, activeElement, 0); + lastCoordX = localx; + lastCoordY = localy; + isMouseDown = false; +} + +void Sandbox::Draw(void* userdata) +{ + Graphics * g = reinterpret_cast<Graphics*>(userdata); + if(!ren) + ren = new Renderer(g, sim); + ren->render_parts(); +} + +void Sandbox::Tick(float delta) +{ + sim->update_particles(); +} + +Sandbox::~Sandbox() { + // TODO Auto-generated destructor stub +} + +} /* namespace ui */ |
