/[projectaxis]/projectaxis/IsoEngine/IsoTileWalker.cpp
ViewVC logotype

Diff of /projectaxis/IsoEngine/IsoTileWalker.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by vovansim, Wed May 28 01:38:54 2003 UTC revision 1.2 by vovansim, Sat Jun 7 03:55:54 2003 UTC
# Line 1  Line 1 
1  /** \file IsoTileWalker.cpp  /** \file IsoTileWalker.cpp
2   * Defines the IsoTileWalker class.   * Defines the IsoTileWalker class.
3   *   *
4     * Revision History:
5     *     v1.1 (June 6) - Optimized the class for square maps.
6     *                     Removed the different function pointers.
7     *                     Removed the map type accessor and modifier.
8     *
9   * @see IsoTileWalker   * @see IsoTileWalker
10   *   *
11   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>
12   * @version 1.0   * @version 1.1
13   * @date May 20, 2003   * @date June 6, 2003
14   */   */
15    
16  #include "IsoTileWalker.h"  #include "IsoTileWalker.h"
17    
 ////////////////////////// Walking function prototypes ////////////////////////  
   
 POINT Iso_SlideTileWalk(POINT start, ISODIRECTION direction);  
 POINT Iso_StagTileWalk(POINT start, ISODIRECTION direction);  
 POINT Iso_DiamondTileWalk(POINT start, ISODIRECTION direction);  
 POINT Iso_RectTileWalk(POINT start, ISODIRECTION direction);  
   
 //////////////////////// End Walking function prototypes //////////////////////  
   
18    
19    
20  ////////////////////////// Construction / Destruction /////////////////////////  ////////////////////////// Construction / Destruction /////////////////////////
# Line 27  POINT Iso_RectTileWalk(POINT start, ISOD Line 23  POINT Iso_RectTileWalk(POINT start, ISOD
23   * Creates a tile walker for the default map type of rectangular.   * Creates a tile walker for the default map type of rectangular.
24   */   */
25  IsoTileWalker::IsoTileWalker() {  IsoTileWalker::IsoTileWalker() {
26          setMapType(ISOMAP_RECTANGULAR);          //Nothing to do
27  }  }
28    
29  IsoTileWalker::~IsoTileWalker() {  IsoTileWalker::~IsoTileWalker() {
# Line 39  IsoTileWalker::~IsoTileWalker() { Line 35  IsoTileWalker::~IsoTileWalker() {
35    
36    
37  POINT IsoTileWalker::walkTile(POINT start, ISODIRECTION direction) {  POINT IsoTileWalker::walkTile(POINT start, ISODIRECTION direction) {
         return walkerFunction(start, direction);  
 }  
   
   
   
 //////////////////////////// Accessors / Modifiers ////////////////////////////  
   
 /** Map type accessor */  
 ISOMAPTYPE IsoTileWalker::getMapType() {  
         return isoMapType;  
 }  
   
 /** Map type modifier */  
 void IsoTileWalker::setMapType(ISOMAPTYPE newMapType) {  
         //Set the map type  
         isoMapType = newMapType;  
   
         //Choose the appropriate plotting function  
         switch(isoMapType) {  
                 case ISOMAP_DIAMOND:  
                         walkerFunction = Iso_DiamondTileWalk;  
                         break;  
   
                 case ISOMAP_RECTANGULAR:  
                         walkerFunction = Iso_RectTileWalk;  
                         break;  
   
                 case ISOMAP_SLIDE:  
                         walkerFunction = Iso_SlideTileWalk;  
                         break;  
   
                 case ISOMAP_STAGGERED:  
                         walkerFunction = Iso_StagTileWalk;  
                         break;  
         }  
 }  
   
 ////////////////////////// End Accessors / Modifiers //////////////////////////  
   
   
   
 /////////////////////////// Actual Walking Functions //////////////////////////  
   
 POINT Iso_SlideTileWalk(POINT start, ISODIRECTION direction) {  
         //Move the starting point depending on which direction we are moving in:  
         switch(direction) {  
                 case IDIR_NORTH:  
                         start.x += 1;  
                         start.y -= 2;  
                         break;  
   
                 case IDIR_NORTHEAST:  
                         start.x += 1;  
                         start.y -= 1;  
                         break;  
   
                 case IDIR_EAST:  
                         start.x += 1;  
                         break;  
   
                 case IDIR_SOUTHEAST:  
                         start.y += 1;  
                         break;  
   
                 case IDIR_SOUTH:  
                         start.x -= 1;  
                         start.y += 2;  
                         break;  
   
                 case IDIR_SOUTHWEST:  
                         start.x -= 1;  
                         start.y += 1;  
                         break;  
   
                 case IDIR_WEST:  
                         start.x -= 1;  
                         break;  
   
                 case IDIR_NORTHWEST:  
                         start.y -= 1;  
                         break;  
         }  
   
         //Return the location we just moved to:  
         return start;  
 }  
   
 POINT Iso_StagTileWalk(POINT start, ISODIRECTION direction) {  
         //Move the starting point depending on which direction we are moving in:  
         switch(direction) {  
                 case IDIR_NORTH:  
                         start.y -= 2;  
                         break;  
   
                 case IDIR_NORTHEAST:  
                         start.x += (start.y & 1);  
                         start.y -= 1;  
                         break;  
   
                 case IDIR_EAST:  
                         start.x += 1;  
                         break;  
   
                 case IDIR_SOUTHEAST:  
                         start.x += (start.y & 1);  
                         start.y += 1;  
                         break;  
   
                 case IDIR_SOUTH:  
                         start.y += 2;  
                         break;  
   
                 case IDIR_SOUTHWEST:  
                         start.x += ((start.y & 1) - 1);  
                         start.y += 1;  
                         break;  
   
                 case IDIR_WEST:  
                         start.x -= 1;  
                         break;  
   
                 case IDIR_NORTHWEST:  
                         start.x += ((start.y & 1) - 1);  
                         start.y -= 1;  
                         break;  
         }  
   
         //Return the location we just moved to:  
         return start;  
 }  
   
 POINT Iso_DiamondTileWalk(POINT start, ISODIRECTION direction) {  
         //Move the starting point depending on which direction we are moving in:  
         switch(direction) {  
                 case IDIR_NORTH:  
                         start.x -= 1;  
                         start.y -= 1;  
                         break;  
   
                 case IDIR_NORTHEAST:  
                         start.y -= 1;  
                         break;  
   
                 case IDIR_EAST:  
                         start.x += 1;  
                         start.y -= 1;  
                         break;  
   
                 case IDIR_SOUTHEAST:  
                         start.x += 1;  
                         break;  
   
                 case IDIR_SOUTH:  
                         start.x += 1;  
                         start.y += 1;  
                         break;  
   
                 case IDIR_SOUTHWEST:  
                         start.y += 1;  
                         break;  
   
                 case IDIR_WEST:  
                         start.x -= 1;  
                         start.y += 1;  
                         break;  
   
                 case IDIR_NORTHWEST:  
                         start.x -= 1;  
                         break;  
         }  
   
         //Return the location we just moved to:  
         return start;  
 }  
   
 POINT Iso_RectTileWalk(POINT start, ISODIRECTION direction) {  
38          //Move the starting point depending on which direction we are moving in:          //Move the starting point depending on which direction we are moving in:
39          switch(direction) {          switch(direction) {
40                  case IDIR_NORTH:                  case IDIR_NORTH:
# Line 256  POINT Iso_RectTileWalk(POINT start, ISOD Line 76  POINT Iso_RectTileWalk(POINT start, ISOD
76    
77          //Return the location we just moved to:          //Return the location we just moved to:
78          return start;          return start;
79  }  }
   
 ///////////////////////// End Actual Walking Functions ////////////////////////  

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26