Hosting courtesy of Sourceforge

SourceForge Logo
Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members  

MapLocation.h

Go to the documentation of this file.
00001 //
00002 //      Copyright (C) 2002 Robert Renaud
00003 //
00004 //      This program is free software; you can redistribute it and/or
00005 //      modify it under the terms of the GNU General Public License
00006 //      as published by the Free Software Foundation; either version 2
00007 //      of the License, or (at your option) any later version.
00008 //
00009 //      This program is distributed in the hope that it will be useful,
00010 //      but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 //      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  
00012 //
00013 //      See the GNU 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 
00020 #ifndef MAP_LOCATION_H
00021 #define MAP_LOCATION_H
00022 
00023 #include "../Config.h"
00024 
00025 #include "SDL.h"
00026 
00027 #include "Constants.h"
00028 #include "GameDebug.h"
00029 
00030 #include "../Parse/ListParser.h"
00031 
00032 namespace Game {
00033 
00037         class MapLocation : public Parse::Parseable {
00038         public:
00039                 MapLocation();
00044                 MapLocation(int x, int y);
00045                 MapLocation(const MapLocation& other);
00046                 Parse::Parser* makeParserToParseMe(std::istream& input);
00047                 
00049                 int getMapX() const;
00050                 
00052                 int getMapY() const;
00053 
00057                 bool operator < (const MapLocation& other) const;
00058                 
00060                 bool operator == (const MapLocation& other) const;
00061         protected:
00062                 int x;
00063                 int y;
00064         };
00065 
00067         class MapLocAt {
00068         public:
00069                 MapLocAt(int x, int y);
00071                 bool operator()(MapLocation* m);
00072         private:
00073                 int x;
00074                 int y;
00075         };
00076 
00077         /* TileFunctions functions used in calculating the number of pixels between
00078         *       between a point and the next tile, and at which tile a specific point is.  The slack
00079         *       functions that take an SDL_Rect& argument are equilivent to the ones that take single
00080         *       Sint16.  If the function is a horizontal one, eg. getRightSlack(const SDL_Rect& pic),
00081         *       it returns the exact same thing that getRightSlack(pic.x) would.  The getDirTile functions
00082         *       return the tile that a given pixel is on.  The offset is positive to the right for the
00083         *       horizontal getDirTile() funcs, and positive upwards for the vertical getDirTile() funcs.
00084         */
00085         
00086         int getDownSlack        (const SDL_Rect& picPosition);  
00087         int getLeftSlack        (const SDL_Rect& picPosition);
00088         int getRightSlack       (const SDL_Rect& picPosition);
00089         int getUpSlack          (const SDL_Rect& picPosition);
00090 
00091         int getDownSlack        (Sint16 y);
00092         int getUpSlack          (Sint16 y);
00093         int getRightSlack       (Sint16 x);
00094         int getLeftSlack        (Sint16 x);
00095 
00096         int getDownTile         (Sint16 y, int offset=0);
00097         int getUpTile           (Sint16 y, int offset=0);
00098         int getRightTile        (Sint16 x, int offset=0);
00099         int getLeftTile         (Sint16 x, int offset=0);
00100 
00105         int getNearestHorizTile(Sint16 xPixel);
00106         int getNearestVertTile(Sint16 yPixel);
00107 
00108         MapLocation getLocation(const SDL_Rect& rect);
00109 };
00110 
00111 #endif
00112 

Generated on Tue May 21 07:26:51 2002 for BomberLAN by doxygen1.2.12 written by Dimitri van Heesch, © 1997-2001