1d301e8dd02e372484f0622ab8a984788115b619
[supertux.git] / src / tile.h
1 //
2 // C++ Interface: tile
3 //
4 // Description: 
5 //
6 //
7 // Author: Tobias Glaesser <tobi.web@gmx.de>, (C) 2004
8 //
9 // Copyright: See COPYING file that comes with this distribution
10 //
11 //
12 #ifndef TILE_H
13 #define TILE_H
14
15 #include <vector>
16 #include "texture.h"
17 #include "globals.h"
18 #include "lispreader.h"
19 #include "setup.h"
20
21 /**
22 Tile Class
23 */
24 struct Tile
25 {
26   int id;
27
28   std::vector<texture_type> images;
29   std::vector<std::string>  filenames;
30
31   /** solid tile that is indestructable by Tux */
32   bool solid;
33
34   /** a brick that can be destroyed by jumping under it */
35   bool brick;
36
37   /** FIXME: ? */
38   bool ice;
39
40   /** Bonusbox, content is stored in \a data */
41   bool fullbox;
42
43   /** Tile is a distro/coin */
44   bool distro;
45
46   /** General purpose data attached to a tile (content of a box, type of coin) */
47   int data;
48
49   /** Id of the tile that is going to replace this tile once it has
50       been collected or jumped at */
51   int next_tile;
52   int next_tile2;
53
54   int anim_speed;
55   unsigned char alpha;
56 };
57
58 class TileManager
59 {
60  private:
61   TileManager();
62   std::vector<Tile*> tiles;
63   static TileManager* instance_ ;
64   void load_tileset(std::string filename);
65   
66  public:
67   static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); }
68   Tile* get(unsigned int id) {
69     if(id < tiles.size())
70       {
71         return tiles[id]; 
72       }
73     else
74       {
75         // Never return 0, but return the 0th tile instead so that
76         // user code doesn't have to check for NULL pointers all over
77         // the place
78         return tiles[0]; 
79       } 
80   }
81 };
82
83 #endif