4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
5 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
27 #include "video/surface.hpp"
28 #include "math/rect.hpp"
29 #include "lisp/lisp.hpp"
39 /// bitset for tile attributes
41 /** solid tile that is indestructable by Tux */
43 /** uni-directional solid tile */
45 /** a brick that can be destroyed by jumping under it */
47 /** the level should be finished when touching a goaltile.
48 * if data is 0 then the endsequence should be triggered, if data is 1
49 * then we can finish the level instantly.
54 /** Bonusbox, content is stored in \a data */
59 /* interesting flags (the following are passed to gameobjects) */
60 FIRST_INTERESTING_FLAG = 0x0100,
62 /** an ice brick that makes tux sliding more than usual */
64 /** a water tile in which tux starts to swim */
66 /** a tile that hurts the player if he touches it */
68 /** for lava: WATER, HURTS, FIRE */
74 WORLDMAP_NORTH = 0x0001,
75 WORLDMAP_SOUTH = 0x0002,
76 WORLDMAP_EAST = 0x0004,
77 WORLDMAP_WEST = 0x0008,
78 WORLDMAP_DIR_MASK = 0x000f,
80 WORLDMAP_STOP = 0x0010,
82 // convenience values ("C" stands for crossroads)
83 WORLDMAP_CNSE = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST,
84 WORLDMAP_CNSW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_WEST,
85 WORLDMAP_CNEW = WORLDMAP_NORTH | WORLDMAP_EAST | WORLDMAP_WEST,
86 WORLDMAP_CSEW = WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST,
87 WORLDMAP_CNSEW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST
91 ImageSpec(const std::string& newfile, const Rect& newrect)
92 : file(newfile), rect(newrect)
102 std::vector<ImageSpec> imagespecs;
103 std::vector<Surface*> images;
108 /** General purpose data attached to a tile (content of a box, type of coin)*/
116 /** Draw a tile on the screen */
117 void draw(DrawingContext& context, const Vector& pos, int z_pos) const;
119 unsigned int getID() const
122 uint32_t getAttributes() const
123 { return attributes; }
128 /// returns the width of the tile in pixels
133 return (int) images[0]->get_width();
136 /// returns the height of the tiles in pixels
137 int getHeight() const
141 return (int) images[0]->get_height();
145 friend class TileManager;
147 Tile(unsigned int id, Uint32 attributes, const ImageSpec& imagespec);
149 void load_images(const std::string& tilesetpath);
151 /// parses the tile and returns it's id number
152 void parse(const lisp::Lisp& reader);
153 void parse_images(const lisp::Lisp& cur);