Main Page | Class Hierarchy | Alphabetical List | Class List | Directories | File List

Location.h

Go to the documentation of this file.
00001 /*
00002 Copyright 2003 - 2005 Elliott Kleinrock, Dan Neely, Kurt W. Over, Damon Domjan
00003 
00004 This file is part of FreeStars, a free clone of the Stars! game.
00005 
00006 FreeStars is free software; you can redistribute it and/or modify
00007 it under the terms of the GNU General Public License as published by
00008 the Free Software Foundation; either version 2 of the License, or
00009 (at your option) any later version.
00010 
00011 FreeStars is distributed in the hope that it will be useful,
00012 but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 GNU General Public License for more details.
00015 
00016 You should have received a copy of the GNU General Public License
00017 along with FreeStars; if not, write to the Free Software
00018 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 
00020 The full GPL Copyright notice should be in the file COPYING.txt
00021 
00022 Contact:
00023 Email Elliott at 9jm0tjj02@sneakemail.com
00024 */
00025 
00030 #if !defined(Location_h)
00031 #define Location_h
00032 
00036 class Location {
00037 public:
00038         Location(const Location &source) : posX(source.posX), posY(source.posY) {}
00039 //      Location(long x, long y) : posX(x), posY(y) {}
00040         Location() : posX(0), posY(0) {}
00041 
00042         virtual ~Location();
00043         virtual bool ParseNode(const TiXmlNode * node);
00044         virtual TiXmlNode * WriteNode(TiXmlNode * node) const   { return WriteLocation(node); }
00045         TiXmlNode * WriteLocation(TiXmlNode * node) const;
00046         virtual const string GetName(const Player *) const      { string s; return s; }
00047 
00048         void SetLocation(const Location & loc)  { posX = loc.posX; posY = loc.posY; }
00049         void SetLocation(long px, long py)              { posX = px; posY = py; }
00050         long GetPosX() const            { return posX; }
00051         long GetPosY() const            { return posY; }
00052         void SetPosX(long x)            { posX = x; }
00053         void SetPosY(long y)            { posY = y; }
00054         double Distance(const Location & other) const;
00055         double Distance(double px, double py) const;
00056         bool IsWith(const Location & other) const       { return posX == other.posX && posY == other.posY; }
00057         bool IsWith(long x, long y) const                       { return posX == x && posY == y; }
00058         virtual long GetID() const              { return 0; }
00059         virtual long SeenBy(const Player *) const       { return true; }
00060         virtual long SeenBy(unsigned long) const        { return true; }
00061 
00062         static void MoveToward(const Location &start, const Location & dest, double * px, double * py, long distance);
00063 
00064         friend bool operator ==(const Location &a, const Location &b)   { return a.IsWith(b); }
00065         friend bool operator !=(const Location &a, const Location &b)   { return !(a == b); }
00066 
00067 protected:
00068         long posX;
00069         long posY;
00070 };
00071 
00072 #endif // !defined(Location_h)

Generated on Mon Aug 8 21:33:43 2005 for Freestars by  doxygen 1.4.2-20050421