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










