sdlmm_spoint.h Source File

Main Page Namespace List Class Hierarchy Compound List File List Namespace Members Compound Members File Members Related Pages

# sdlmm_spoint.h

Go to the documentation of this file.

    00001 /*
    00002  * SDLmm - a C++ wrapper for SDL and related libraries
    00003  * Copyright © 2001 David Hedbor <david@hedbor.org>
    00004  *
    00005  * This program is free software; you can redistribute it and/or
    00006  * modify it under the terms of the GNU General Public License as
    00007  * published by the Free Software Foundation; either version 2 of the
    00008  * License, or (at your option) any later version.
    00009  *
    00010  * This program is distributed in the hope that it will be useful, but
    00011  * WITHOUT ANY WARRANTY; without even the implied warranty of
    00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00013  * General Public License for more details.
    00014  *
    00015  * You should have received a copy of the GNU General Public License
    00016  * along with this program; if not, write to the Free Software
    00017  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
    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

Documentation automatically generated by written by Dimitri van Heesch. | Project hosted at