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

Diff of /projectaxis/IsoEngine/IsoTilePlotter.cpp

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

revision 1.2 by vovansim, Sat Jun 7 03:55:54 2003 UTC revision 1.3 by vovansim, Sat Sep 13 21:40:20 2003 UTC
# Line 1  Line 1 
1  /** \file IsoTilePlotter.cpp  /** \file IsoTilePlotter.cpp
2   * Defines the TilePlotter class.   * Defines the TilePlotter class.
3   *   *
  * Revision History:  
  *     v1.1 (June 6) - Optimized the class for square maps.  
  *                     Removed the different function pointers.  
  *                     Removed the map type accessor and modifier.  
  *  
4   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>   * @author <A href="mailto:vovansim@hotmail.com">Vovansim (aka Scorpion)</A>
5   * @version 1.1   * @version 1.0
6   * @date June 6, 2003   * @date May 17, 2003
7   */   */
8    
9  #include "IsoTilePlotter.h"  #include "IsoTilePlotter.h"
10  #include "IsoGeometryTools.h"  #include "IsoGeometryTools.h"
11    
12    ///////////////////////// Plotting function prototypes ////////////////////////
13    
14    POINT Iso_SlidePlotTile(POINT coords, int tileWidth, int tileHeight);
15    POINT Iso_StagPlotTile(POINT coords, int tileWidth, int tileHeight);
16    POINT Iso_DiamondPlotTile(POINT coords, int tileWidth, int tileHeight);
17    POINT Iso_RectPlotTile(POINT coords, int tileWidth, int tileHeight);
18    
19    /////////////////////// End Plotting function prototypes //////////////////////
20    
21    
22    
23  ////////////////////////// Construction / Destruction /////////////////////////  ////////////////////////// Construction / Destruction /////////////////////////
# Line 23  Line 27 
27   * rectangular map, and the tile size is 1x1.   * rectangular map, and the tile size is 1x1.
28   */   */
29  IsoTilePlotter::IsoTilePlotter() {  IsoTilePlotter::IsoTilePlotter() {
30            // Set the default map type to rectangular
31            setMapType(ISOMAP_RECTANGULAR);
32    
33          // Set the default tile size to 1x1          // Set the default tile size to 1x1
34          setTileSize(1, 1);          setTileSize(1, 1);
35  }  }
# Line 36  IsoTilePlotter::~IsoTilePlotter() { Line 43  IsoTilePlotter::~IsoTilePlotter() {
43    
44    
45  POINT IsoTilePlotter::plotTile(POINT coords) {  POINT IsoTilePlotter::plotTile(POINT coords) {
46          //The result of the operation          return plotterFunction(coords, tileWidth, tileHeight);
         POINT result;  
   
         //Calculate the x coordinate:  
         result.x = coords.x * tileWidth;  
   
         //Calculate the y coordinate:  
         result.y = coords.y * tileHeight;  
   
         //Return the result  
         return result;    
47  }  }
48    
49    
50    
51  //////////////////////////// Accessors / Modifiers ////////////////////////////  //////////////////////////// Accessors / Modifiers ////////////////////////////
52    
53    /** Map type accessor */
54    ISOMAPTYPE IsoTilePlotter::getMapType() {
55            return isoMapType;
56    }
57    
58    /** Map type modifier */
59    void IsoTilePlotter::setMapType(ISOMAPTYPE newMapType) {
60            //Set the map type
61            isoMapType = newMapType;
62    
63            //Choose the appropriate plotting function
64            switch(isoMapType) {
65                    case ISOMAP_DIAMOND:
66                            plotterFunction = Iso_DiamondPlotTile;
67                            break;
68    
69                    case ISOMAP_RECTANGULAR:
70                            plotterFunction = Iso_RectPlotTile;
71                            break;
72    
73                    case ISOMAP_SLIDE:
74                            plotterFunction = Iso_SlidePlotTile;
75                            break;
76    
77                    case ISOMAP_STAGGERED:
78                            plotterFunction = Iso_StagPlotTile;
79                            break;
80            }
81    }
82    
83  int IsoTilePlotter::getTileWidth() {  int IsoTilePlotter::getTileWidth() {
84          return tileWidth;          return tileWidth;
85  }  }
# Line 70  void IsoTilePlotter::setTileSize(int new Line 97  void IsoTilePlotter::setTileSize(int new
97          tileHeight = newTileHeight;          tileHeight = newTileHeight;
98  }  }
99    
 ////////////////////////// End Accessors / Modifiers //////////////////////////  
100    ////////////////////////// End Accessors / Modifiers //////////////////////////
101    
102    
103    
104    ////////////////////////// Actual Plotting Functions //////////////////////////
105    
106    POINT Iso_SlidePlotTile(POINT coords, int tileWidth, int tileHeight) {
107            //The result of the operation
108            POINT result;
109    
110            //Calculate the x coordinate:
111            result.x = coords.x * tileWidth + coords.y * (tileWidth >> 1);
112    
113            //Calculate the y coordinate:
114            result.y = coords.y * (tileHeight >> 1);
115    
116            //Return the result
117            return result;
118    }
119    
120    POINT Iso_StagPlotTile(POINT coords, int tileWidth, int tileHeight) {
121            //The result of the operation
122            POINT result;
123    
124            //Calculate the x coordinate:
125            result.x = coords.x * tileWidth + (coords.y & 1) * (tileWidth >> 1);
126    
127            //Calculate the y coordinate:
128            result.y = coords.y * (tileHeight >> 1);
129    
130            //Return the result
131            return result;
132    }
133    
134    POINT Iso_DiamondPlotTile(POINT coords, int tileWidth, int tileHeight) {
135            //The result of the operation
136            POINT result;
137    
138            //Calculate the x coordinate:
139            result.x = (coords.x - coords.y) * (tileWidth >> 1);
140    
141            //Calculate the y coordinate:
142            result.y = (coords.x + coords.y) * (tileHeight >> 1);
143    
144            //Return the result
145            return result;
146    }
147    
148    POINT Iso_RectPlotTile(POINT coords, int tileWidth, int tileHeight) {
149            //The result of the operation
150            POINT result;
151    
152            //Calculate the x coordinate:
153            result.x = coords.x * tileWidth;
154    
155            //Calculate the y coordinate:
156            result.y = coords.y * tileHeight;
157    
158            //Return the result
159            return result;
160    }
161    
162    //////////////////////// End Actual Plotting Functions ////////////////////////

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

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