source:
code/trunk/src/modules/towerdefense/TDCoordinate.cc
@
11479
Last change on this file since 11479 was 11083, checked in by muemart, 9 years ago | |
---|---|
|
|
File size: 1.1 KB |
Rev | Line | |
---|---|---|
[10105] | 1 | #include "TDCoordinate.h" |
2 | ||
3 | #include "towerdefense/TowerDefensePrereqs.h" | |
4 | ||
5 | ||
6 | ||
7 | ||
8 | namespace orxonox | |
9 | { | |
10 | /** | |
11 | @brief | |
[10629] | 12 | Constructor. Sets the default coordinates: (0,0) |
[10105] | 13 | */ |
14 | TDCoordinate::TDCoordinate() | |
15 | { | |
[10622] | 16 | Set(0,0); |
[10105] | 17 | } |
18 | ||
19 | TDCoordinate::TDCoordinate(int x, int y) | |
[10622] | 20 | { |
21 | Set(x,y); | |
[10105] | 22 | } |
23 | ||
[10622] | 24 | void TDCoordinate::Set(int x, int y) |
25 | { | |
26 | if (x < 0) | |
27 | { | |
28 | _x = 0; | |
29 | } | |
30 | else if (x > 15) | |
31 | { | |
32 | _x = 15; | |
33 | } | |
34 | else | |
35 | { | |
36 | _x = x; | |
37 | } | |
[10105] | 38 | |
[10622] | 39 | if (y < 0) |
40 | { | |
41 | _y = 0; | |
42 | } | |
43 | else if (y > 15) | |
44 | { | |
45 | _y = 15; | |
46 | } | |
47 | else | |
48 | { | |
49 | _y = y; | |
50 | } | |
51 | } | |
52 | ||
53 | int TDCoordinate::GetX() | |
54 | { | |
55 | return _x; | |
56 | } | |
57 | ||
58 | int TDCoordinate::GetY() | |
59 | { | |
60 | return _y; | |
61 | } | |
62 | ||
63 | ||
[10105] | 64 | Vector3 TDCoordinate::get3dcoordinate() |
65 | { | |
[10246] | 66 | float tileScale = 100; |
[10105] | 67 | |
[11083] | 68 | Vector3 coord; |
69 | coord.x= (_x-8) * tileScale; | |
70 | coord.y= (_y-8) * tileScale; | |
71 | coord.z=0; | |
[10105] | 72 | |
[11083] | 73 | return coord; |
[10105] | 74 | } |
75 | } |
Note: See TracBrowser
for help on using the repository browser.