Jamoma API  0.6.0.a19
Moveable.cpp
1 // Implements methods for base class Moveable
2 
3 #include "Moveable.h"
4 #include "ext.h"
5 #include "Coordinate.h"
6 
7 extern bool globWarningFlag;
8 extern bool globReportFlag;
9 
11 {
12  xPos_ = Coordinate(0.0);
13  yPos_ = Coordinate(0.0);
14  zPos_ = Coordinate(0.0);
15  flag_ = true;
16 }
17 
18 Moveable::Moveable(double x, double y, double z)
19 {
20  xPos_ = Coordinate(x);
21  yPos_ = Coordinate(y);
22  zPos_ = Coordinate(z);
23  flag_ = true;
24 }
25 
26 double Moveable::xPos() const
27 {
28  return xPos_();
29 }
30 
31 void Moveable::xPos(double x)
32 {
33  xPos_(x);
34  if (globReportFlag)
35  printPos();
36  flag_ = true;
37 }
38 
39 double Moveable::yPos() const
40 {
41  return yPos_();
42 }
43 
44 void Moveable::yPos(double y)
45 {
46  yPos_(y);
47  if (globReportFlag)
48  printPos();
49  flag_ = true;
50 }
51 
52 double Moveable::zPos() const
53 {
54  return zPos_();
55 }
56 
57 void Moveable::zPos(double z)
58 {
59  zPos_(z);
60  if (globReportFlag)
61  printPos();
62  flag_ = true;
63 }
64 
65 bool Moveable::flag() const
66 {
67  return flag_;
68 }
69 
70 void Moveable::flag(bool changed)
71 {
72  flag_ = changed;
73 }
74 
75 bool Moveable::checkWidth(double newWidth)
76 {
77  return ((newWidth * 0.5) >= abs(xPos_()));
78 }
79 
80 bool Moveable::checkDepth(double newDepth)
81 {
82  return ((newDepth * 0.5) >= abs(yPos_()));
83 }
84 
85 bool Moveable::checkHeight(double newHeight)
86 {
87  return ((newHeight * 0.5) >= abs(zPos_()));
88 }
89 
90 // vim:sw=4:et:cindent:
bool checkDepth(double newDepth)
Check if a room's new depth will still contain this object.
Definition: Moveable.cpp:80
virtual void printPos() const =0
Virtual function that must be overriden in derived classes. Prints position for this object...
Coordinate class.
Definition: Coordinate.h:15
double xPos() const
Get x position.
Definition: Moveable.cpp:26
bool flag() const
True if object has moved.
Definition: Moveable.cpp:65
bool checkWidth(double newWidth)
Check if a room's new width will still contain this object.
Definition: Moveable.cpp:75
bool checkHeight(double newHeight)
Check if a room's new height will still contain this object.
Definition: Moveable.cpp:85
double zPos() const
Get z position.
Definition: Moveable.cpp:52
Moveable()
Class constructor.
Definition: Moveable.cpp:10
double yPos() const
Get y position.
Definition: Moveable.cpp:39