Gel2D - The free/open source game creation suite

gelSize.h
Go to the documentation of this file.
00001 /*
00002 Gel2D Game Engine - Cross-platform 2D gaming middleware
00003 Copyright (C) 2011 Mark D. Procarione
00004 
00005 Gel2D is free software: you can redistribute it and/or modify
00006 it under the terms of the GNU General Public License as published by
00007 the Free Software Foundation, either version 3 of the License, or
00008 (at your option) any later version.
00009 
00010 Gel2D is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 GNU General Public License for more details.
00014 */
00015 
00016 #ifndef __GELSIZE_H__
00017 #define __GELSIZE_H__
00018 
00019 namespace gel
00020 {
00021     class GelSize
00022     {
00023         public:
00025 
00026             GelSize() : width(0), height(0) {}
00027 
00029 
00030             GelSize( int n ) : width(n), height(n) {}
00031 
00033 
00035             GelSize( int w, int h ) : width(w), height(h) {}
00036 
00038             GelSize( const GelSize &size) { width = size.width; height = size.height; }
00039 
00040             GelSize operator+ ( const GelSize &s ) const { return GelSize( width+s.width, height+s.height ); }
00041             GelSize operator- ( const GelSize &s ) const { return GelSize( width-s.width, height-s.height ); }
00042             GelSize operator* ( const GelSize &s ) const { return GelSize( width*s.width, height*s.height ); }
00043             GelSize operator/ ( const GelSize &s ) const { return GelSize( width/s.width, height/s.height ); }
00044             GelSize operator= ( const GelSize &s ) { width=s.width; height=s.height; return *this; }
00045             GelSize operator+=( const GelSize &s ) { width+=s.width; height+=s.height; return *this; }
00046             GelSize operator-=( const GelSize &s ) { width-=s.width; height-=s.height; return *this; }
00047             GelSize operator*=( const GelSize &s ) { width*=s.width; height*=s.height; return *this; }
00048             GelSize operator/=( const GelSize &s ) { width/=s.width; height/=s.height; return *this; }
00049 
00050             bool operator==( const GelSize &s ) const { return ( width==s.width && height==s.height ); }
00051             bool operator!=( const GelSize &s ) const { return ( width!=s.width || height!=s.height ); }
00052             bool operator< ( const GelSize &s ) const { return ( width<s.width || (width==s.width && height<s.height) ); }
00053             bool operator> ( const GelSize &s ) const { return ( width>s.width || (width==s.width && height>s.height) ); }
00054 
00055         public:
00057             int width;
00059             int height;
00060     };
00061 
00062     class GelPoint
00063     {
00064         public:
00066 
00067             GelPoint() : x(0), y(0) {}
00068 
00070 
00071             GelPoint( int n ) : x(n), y(n) {}
00072 
00074 
00076             GelPoint( int _x, int _y ) : x(_x), y(_y) {}
00077 
00079             GelPoint( const GelPoint &point) : x(point.x), y(point.y) {}
00080 
00081             GelPoint operator+ ( const GelPoint &p ) const { return GelPoint( x+p.x, y+p.y ); }
00082             GelPoint operator- ( const GelPoint &p ) const { return GelPoint( x-p.x, y-p.y ); }
00083             GelPoint operator* ( const GelPoint &p ) const { return GelPoint( x*p.x, y*p.y ); }
00084             GelPoint operator/ ( const GelPoint &p ) const { return GelPoint( x/p.x, y/p.y ); }
00085             GelPoint operator= ( const GelPoint &p ) { x=p.x; y=p.y; return *this; }
00086             GelPoint operator+=( const GelPoint &p ) { x+=p.x; y+=p.y; return *this; }
00087             GelPoint operator-=( const GelPoint &p ) { x-=p.x; y-=p.y; return *this; }
00088             GelPoint operator*=( const GelPoint &p ) { x*=p.x; y*=p.y; return *this; }
00089             GelPoint operator/=( const GelPoint &p ) { x/=p.x; y/=p.y; return *this; }
00090 
00091             bool operator==( const GelPoint &p ) const { return ( x==p.x && y==p.y ); }
00092             bool operator!=( const GelPoint &p ) const { return ( x!=p.x || y!=p.y ); }
00093             bool operator< ( const GelPoint &p ) const { return ( x<p.x || (x==p.x && y<p.y) ); }
00094             bool operator> ( const GelPoint &p ) const { return ( x>p.x || (x==p.x && y>p.y) ); }
00095 
00096         public:
00098             int x;
00100             int y;
00101     };
00102 }
00103 
00104 #endif // __GELSIZE_H__