summaryrefslogtreecommitdiff
path: root/src/interface
diff options
context:
space:
mode:
Diffstat (limited to 'src/interface')
-rw-r--r--src/interface/Sandbox.cpp23
-rw-r--r--src/interface/State.cpp15
2 files changed, 29 insertions, 9 deletions
diff --git a/src/interface/Sandbox.cpp b/src/interface/Sandbox.cpp
index c33571a..5e29bae 100644
--- a/src/interface/Sandbox.cpp
+++ b/src/interface/Sandbox.cpp
@@ -5,35 +5,54 @@
* 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)
+ 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_parts(localx, localy, 20, 20, 1, 0);
+ 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;
}
diff --git a/src/interface/State.cpp b/src/interface/State.cpp
index e069e8f..2828751 100644
--- a/src/interface/State.cpp
+++ b/src/interface/State.cpp
@@ -13,13 +13,14 @@
namespace ui {
-State::State(int w, int h) :
- mouseX(0),
- mouseY(0),
- mouseXP(0),
- mouseYP(0),
- width(w),
- height(h)
+State::State(int w, int h):
+ mouseX(0),
+ mouseY(0),
+ mouseXP(0),
+ mouseYP(0),
+ width(w),
+ height(h),
+ Components()
{
}