summaryrefslogtreecommitdiff
path: root/src/interface/Sandbox.cpp
blob: c33571a146006d62be453fa64ea29dba7c5c7f2a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*
 * Sandbox.cpp
 *
 *  Created on: Jan 8, 2012
 *      Author: Simon
 */

#include "Config.h"

#include "interface/Sandbox.h"
#include "interface/Component.h"
#include "Renderer.h"

namespace ui {

Sandbox::Sandbox():
		Component(0, 0, XRES, YRES)
{
	sim = new Simulation();
}

void Sandbox::OnMouseMovedInside(int localx, int localy, int dx, int dy)
{
	if(isMouseDown)
	{
		sim->create_parts(localx, localy, 20, 20, 1, 0);
	}
}

void Sandbox::OnMouseDown(int localx, int localy, unsigned int button)
{
	isMouseDown = true;
}

void Sandbox::OnMouseUp(int localx, int localy, unsigned int button)
{
	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 */