00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 #ifndef SDLMM_SPOINT_H
00022 #define SDLMM_SPOINT_H
00023 
00024 namespace SDLmm {
00030   class SPoint {
00031   public:
00034     SPoint() : x(0), y(0) {
00035     }
00036 
00039 
00040     SPoint(const SPoint& point) : x(point.x), y(point.y) {
00041     }
00042 
00044 
00048     SPoint(Sint16 nx, Sint16 ny) : x(nx), y(ny) {  }
00049 
00051     SPoint& operator=(const SPoint& point) {
00052       if(this != &point)
00053       {
00054         x = point.x;
00055         y = point.y;
00056       }
00057       return *this;
00058     }
00059 
00061 
00064     bool operator==(const SPoint& point) const {
00065       return ((x == point.x) && (y == point.y));
00066     }
00067 
00072     bool operator<(const SPoint &point) const {
00073       return x < point.x && y < point.y;
00074     }
00075 
00080     bool operator<=(const SPoint &point) const {
00081       return x <= point.x && y <= point.y;
00082     }
00083     
00088     bool operator>(const SPoint &point) const {
00089       return !operator<(point);
00090     }
00095     bool operator>=(const SPoint &point) const {
00096       return !operator<=(point);
00097     }
00098 
00099     SPoint& operator+=(const SPoint& point) {
00100       x += point.x;
00101           y += point.y;
00102           return *this;
00103     }
00104 
00105     SPoint& operator-=(const SPoint& point) {
00106       x -= point.x;
00107           y -= point.y;
00108           return *this;
00109     }
00110 
00111     SPoint operator+(const SPoint& point) const {
00112       return SPoint(x + point.x, y + point.y);
00113     }
00114 
00115     SPoint operator-(const SPoint& point) const {
00116       return SPoint(x - point.x, y - point.y);
00117     }
00118 
00119     SPoint& operator*=(Sint16 scalar) {
00120       x *= scalar;
00121           y *= scalar;
00122           return *this;
00123     }
00124 
00125     SPoint& operator/=(Sint16 scalar) {
00126       x /= scalar;
00127           y /= scalar;
00128           return *this;
00129     }
00130 
00131     SPoint operator*(Sint16 scalar) const {
00132       return SPoint(x * scalar, y * scalar);
00133     }
00134 
00135     SPoint operator/(Sint16 scalar) const {
00136       return SPoint(x / scalar, y / scalar);
00137     }
00138 
00139     Sint16 x;
00140     Sint16 y;
00141   };
00142 }
00143 
00144 #endif // SDLMM_SPOINT_H
00145