Added slope tiles.
[supertux.git] / src / tile.h
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program 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 this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20
21 #ifndef TILE_H
22 #define TILE_H
23
24 #include <vector>
25 #include "SDL.h"
26 #include "screen/surface.h"
27
28 class Vector;
29 class LispReader;
30
31 /**
32 Tile Class
33 */
34 class Tile
35 {
36 public:
37   Tile();
38   ~Tile();
39
40   /// parses the tile and returns it's id number
41   int read(LispReader& reader);
42
43   int id;
44
45   std::vector<Surface*> images;
46   std::vector<Surface*> editor_images;
47   
48   /// bitset for tileflags
49   enum {
50       /** solid tile that is indestructable by Tux */
51       SOLID     = 0x0001,
52       /** uni-directional solid tile */
53       UNISOLID  = 0x0002,
54       /** a brick that can be destroyed by jumping under it */
55       BRICK     = 0x0004,
56       /** an ice brick that makes tux sliding more than usual */
57       ICE       = 0x0008,
58       /** a water tile in which tux starts to swim */
59       WATER     = 0x0010,
60       /** a tile that hurts the player if he touches it */
61       SPIKE     = 0x0020,
62       /** Bonusbox, content is stored in \a data */
63       FULLBOX   = 0x0040,
64       /** Tile is a coin */
65       COIN      = 0x0080,
66       /** the level should be finished when touching a goaltile.
67        * if data is 0 then the endsequence should be triggered, if data is 1
68        * then we can finish the level instantly.
69        */
70       GOAL      = 0x0100
71   };
72
73   /** tile attributes */
74   Uint32 attributes;
75   
76   /** General purpose data attached to a tile (content of a box, type of coin)*/
77   int data;
78
79   /** Id of the tile that is going to replace this tile once it has
80       been collected or jumped at */
81   int next_tile;
82
83   int anim_speed;
84
85   /** This is the angle of the slope. Set to 0, if this is no slope. */
86   float slope_angle;
87   
88   /** Draw a tile on the screen: */
89   static void draw(const Vector& pos, unsigned int c, Uint8 alpha = 255);
90
91   /// returns the width of the tile in pixels
92   int getWidth() const
93   { 
94     if(!images.size())
95       return 0;
96     return images[0]->w;
97   }
98
99   /// returns the height of the tiles in pixels
100   int getHeight() const
101   {
102     if(!images.size())
103       return 0;
104     return images[0]->h;
105   }
106 };
107
108 #endif
109
110 /* EOF */