summaryrefslogtreecommitdiff
path: root/src/game/Tool.h
blob: 00b11844b2f4bb3e0e39c94c474a5dbd4e60c79b (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/*
 * Tool.h
 *
 *  Created on: Jan 22, 2012
 *      Author: Simon
 */

#ifndef TOOL_H_
#define TOOL_H_

#include <iostream>

using namespace std;

class Tool
{
protected:
	int toolID;
	string toolName;
public:
	Tool(int id, string name, int r, int g, int b):
		toolID(id),
		toolName(name),
		colRed(r),
		colGreen(g),
		colBlue(b)
	{
	}
	string GetName() { return toolName; }
	virtual ~Tool() {}
	virtual void Draw(Simulation * sim, Brush * brush, ui::Point position) {}
	virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
	virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {}
	virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {};
	int colRed, colBlue, colGreen;
};

class ElementTool: public Tool
{
public:
	ElementTool(int id, string name, int r, int g, int b):
		Tool(id, name, r, g, b)
	{
	}
	virtual ~ElementTool() {}
	virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
		sim->create_parts(position.X, position.Y, 1, 1, toolID, 0, brush);
	}
	virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
		sim->create_line(position1.X, position1.Y, position2.X, position2.Y, 1, 1, toolID, 0, brush);
	}
	virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
		sim->create_box(position1.X, position1.Y, position2.X, position2.Y, toolID, 0);
	}
	virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
		sim->flood_parts(position.X, position.Y, toolID, -1, -1, 0);
	}
};

class GolTool: public Tool
{
public:
	GolTool(int id, string name, int r, int g, int b):
		Tool(id, name, r, g, b)
	{
	}
	virtual ~GolTool() {}
	virtual void Draw(Simulation * sim, Brush * brush, ui::Point position){
		sim->create_parts(position.X, position.Y, 1, 1, PT_LIFE|(toolID<<8), 0, brush);
	}
	virtual void DrawLine(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
		sim->create_line(position1.X, position1.Y, position2.X, position2.Y, 1, 1, PT_LIFE|(toolID<<8), 0, brush);
	}
	virtual void DrawRect(Simulation * sim, Brush * brush, ui::Point position1, ui::Point position2) {
		sim->create_box(position1.X, position1.Y, position2.X, position2.Y, PT_LIFE|(toolID<<8), 0);
	}
	virtual void DrawFill(Simulation * sim, Brush * brush, ui::Point position) {
		sim->flood_parts(position.X, position.Y, PT_LIFE|(toolID<<8), -1, -1, 0);
	}
};

#endif /* TOOL_H_ */