Map.h

00001 
00002 #ifndef _Map_H_
00003 #define _Map_H_
00004 
00005 #include "renderer.h"
00006 #include "Entity2D.h"
00007 #include "TextureManager.h"
00008 #include "AmeFormat.h"
00009 #include <iostream>
00010 
00011 #define MAP_TILE_WIDTH          64
00012 #define MAP_TILE_HEIGHT         64
00013 
00014 namespace zak {
00015 
00016 class Tiles {
00017         public:
00018                 float _fPosX, _fPosY, _fU, _fV, _fUW, _fUH;
00019 };
00020 
00045 class ZAKENGINE_API Map : public Entity2D {
00046         private:
00047                 TexVertex       *_Vertex;
00048                 TexVertex       *_TempVert;
00049                 Texture         *_pTexture;
00050                 float           _fUV[2];                // UV de la textura a usar
00051                 float           _fW;                    // Ancho del tile
00052                 float           _fH;                    // Alto del tile
00053 
00054                 int                     _iStartX,_iStartY;
00055                 int                     _iCountX,_iCountY;
00056                 int                     _iTempCountX,_iTempCountY;
00057 
00058                 int                     *_cMap;
00059                 ameHeader       *_ame;
00060                 Tiles           *_Tiles;
00061 
00062                 int                     _iActualTile;
00063                 int                     _iTileWidth;
00064                 int                     _iTileHeight;
00065 
00066                 int                     _iWidth;
00067                 int                     _iHeight;
00068                 
00069                 bool            _bEnableAlpha;
00070 
00071                 bool LoadTexture(const char *pszTextureFilename, unsigned int uiColorKey, bool persist = false, DWORD filter=2, DWORD mipFilter=2); 
00072                 bool LoadMap    (const char *pszMapFilename);
00073                 bool LoadAnacondaMap(const char *pszMapFilename);
00074 
00075 
00076                 static void Constructor(Map *map){
00077                         new(map) Map();
00078                 }
00079                 static void Destructor(Map *map){
00080                         map->~Map();
00081                 }
00082 
00083                 static void ConstructArray(vector<Map> *self) {
00084                         new(self) vector<Map>();
00085                 }
00086 
00087                 static void ConstructArray(int length, vector<Map> *self) {
00088                         new(self) vector<Map>(length);
00089                 }
00090 
00091                 static void DestructArray(vector<Map> *self) {
00092                         self->~vector();
00093                 }
00094 
00095 
00096         public:
00100                 void EnableAlphaBlend () {
00101                         _bEnableAlpha = true;
00102                 }
00103 
00107                 void DisableAlphaBlend () {
00108                         _bEnableAlpha = false;
00109                 }
00110 
00115                 int      GetTileWidth() {
00116                         return _iTileWidth;
00117                 }
00122                 int      GetTileHeight() {
00123                         return _iTileHeight;
00124                 }
00125 
00130                 int GetMapWidth() {
00131                         return _iWidth;
00132                 }
00137                 int GetMapHeight() {
00138                         return _iHeight;
00139                 }
00140 
00147                 void SetTile (int col, int row, int tileNum);
00148 
00155                 int GetTileFromWorldCoords(float x, float y);
00156 
00163                 int GetTileFromColRow(int col, int row);
00164 
00173                 bool GetColRowFromWorldCoords(float x, float y, int &col, int &row);
00174 
00183                 bool GetWorldCoordsFromColRow(int col, int row, float &x, float &y);
00184 
00192                 bool GetColRowFromTile(int tile, int &col, int &row);
00193 
00201                 bool GetWorldCoordsFromTile(int tile, float &x, float &y);
00202 
00208                 int      GetTileNumCount(int tile);
00209 
00216                 ameBlockInfo *GetAmeTileInfoFromColRow(int col, int row);
00217 
00224                 ameBlockInfo *GetAmeTileInfoFromWorldCoords(float x, float y);
00225 
00230                 ameHeader *GetAmeMapDetails() { return _ame; } 
00231 
00242                 bool Load               (const char *pszTextureFilename, const char *pszMapFilename, unsigned int uiColorKey, int tileWidth, int tileHeight, bool persist = false, DWORD filter=2, DWORD mipFilter=2);
00243 
00252                 bool Load               (const char *pszTextureFilename, const char *pszMapFilename, unsigned int uiColorKey, bool persist = false, DWORD filter=2, DWORD mipFilter=2);
00253 
00262                 bool LoadAMF    (const char *pszMapFilename, unsigned int uiColorKey, bool persist = false, DWORD filter=2, DWORD mipFilter=2);
00263 
00264                 bool Load               (string &pszMapFilename, unsigned int uiColorKey, bool persist = false, DWORD filter=2, DWORD mipFilter=2) { return LoadAMF(pszMapFilename.c_str(), uiColorKey, persist, filter, mipFilter);}
00265 
00270                 bool Unload();
00271 
00275                 void Draw               ();
00276 
00277 
00278                 static bool RegisterMap(char *className=NULL);
00279 
00283         Map();
00284 
00288         ~Map();
00289 };
00290 
00291 }
00292 #endif // _Map_H_

Generado el Tue May 29 14:46:14 2007 para Zak Engine v1.1.0 por  doxygen 1.5.1-p1