1 /*-----------------------------------------------------------------------------
2 Copyright 2003 Milan Babuskov
3 
4 This file is part of Njam (http://njam.sourceforge.net).
5 
6 Njam is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10 
11 Njam is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15 
16 You should have received a copy of the GNU General Public License
17 along with Njam in file COPYING; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19 -----------------------------------------------------------------------------*/
20 #ifndef NJAM_MAP_H
21 #define NJAM_MAP_H
22 //---------------------------------------------------------------------------
23 #define MAPS 20
24 #define MAPW 28
25 #define MAPH 24
26 //---------------------------------------------------------------------------
27 typedef enum { ttWall=0,	ttEmpty,	ttGHouse,	ttDoor,			ttJuice,	ttCookie,
28                ttFreezer,	ttTrap,		ttTeleport,	ttInvisible, 	ttPoints,	ttGHouseActive
29 } TileType;
30 //---------------------------------------------------------------------------
31 typedef struct
32 {
33  	int x;
34  	int y;
35  	bool Invalid;
36 } MapPoint;
37 //---------------------------------------------------------------------------
38 class NjamMap
39 {
40 private:
41     SDL_Surface *m_Images;
42     int m_TileW, m_TileH;
43     Uint8 m_Tiles[MAPS+1][MAPW][MAPH];	// MAPS+1 since last map is used for playing (it's a copy of actual map)
44 
45 public:
46     void Clear();
47 	void ClearCurrent();
48 	void AddPowerups(int HowMuch);
49     int  CrossRoads(int x, int y);
50     MapPoint FindSpecificTile(TileType type);
51 	int CountSpecificTiles(TileType type);
52 	MapPoint FindOtherTeleport(int x, int y);
53 	TileType GetTile(int x, int y);
54     Uint8 *GetTiles();
55     MapPoint GhostHouseXY();
56 	bool IsOk(int MapNumber);
57     int  Load(const char *file);
58 	void RevertToMap(int map);
59 	void SwapMaps(int map1, int map2);
60     void RenderMap(SDL_Surface *Destination, int x, int y);
61     void RenderMap(SDL_Surface *Destination);
62 	void SetCurrentMap(int NewCurrentMap);
63     void SetMapImages(SDL_Surface *, int TileW, int TileH);
64     void SetTile(int x, int y, TileType Value);
65     bool Save(const char *file);
66 	void TurnOnCrossRoads(int x, int y, int& dx, int& dy, int Choice);
67 	int SelectMap(char type, SDL_Surface *screen, NjamFont *font);
68     NjamMap();
69 };
70 //---------------------------------------------------------------------------
71 #endif
72 
73