Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tgidronFS16/src/modules/towerdefense/TDCoordinate.cc @ 12035

Last change on this file since 12035 was 11083, checked in by muemart, 9 years ago

Fix some clang-tidy warnings.
Also, Serialise.h was doing some C-style casts that ended up being const casts. I moved those const casts as close to the source as possible and changed the loadAndIncrease functions to not do that.

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1#include "TDCoordinate.h"
2
3#include "towerdefense/TowerDefensePrereqs.h"
4
5
6
7
8namespace orxonox
9{
10    /**
11    @brief
12        Constructor. Sets the default coordinates: (0,0)
13    */
14    TDCoordinate::TDCoordinate()
15    {
16        Set(0,0);
17    }
18
19    TDCoordinate::TDCoordinate(int x, int y)
20    {       
21        Set(x,y);
22    }
23
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        }
38
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
64    Vector3 TDCoordinate::get3dcoordinate()
65    {
66        float tileScale = 100;
67
68        Vector3 coord;
69        coord.x= (_x-8) * tileScale;
70        coord.y= (_y-8) * tileScale;
71        coord.z=0;
72
73        return coord;
74    }
75}
Note: See TracBrowser for help on using the repository browser.