We have our own mouse-cursor now! (graphics by Settra Gaia)
[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
59 class TileManager
60 {
61  private:
62   TileManager();
63   std::vector<Tile*> tiles;
64   static TileManager* instance_ ;
65   void load_tileset(std::string filename);
66   
67  public:
68   static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); }
69   Tile* get(unsigned int id) {
70     if(id < tiles.size())
71       {
72         return tiles[id]; 
73       }
74     else
75       {
76         // Never return 0, but return the 0th tile instead so that
77         // user code doesn't have to check for NULL pointers all over
78         // the place
79         return tiles[0]; 
80       } 
81   }
82 };
83
84
85
86 #endif