2 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
3 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef HEADER_SUPERTUX_SUPERTUX_TILE_HPP
19 #define HEADER_SUPERTUX_SUPERTUX_TILE_HPP
24 #include "math/rectf.hpp"
25 #include "video/surface.hpp"
26 #include "util/reader_fwd.hpp"
34 static bool draw_editor_images;
35 /// bitset for tile attributes
37 /** solid tile that is indestructible by Tux */
39 /** uni-directional solid tile */
41 /** a brick that can be destroyed by jumping under it */
43 /** the level should be finished when touching a goaltile.
44 * if data is 0 then the endsequence should be triggered, if data is 1
45 * then we can finish the level instantly.
50 /** Bonusbox, content is stored in \a data */
55 /* interesting flags (the following are passed to gameobjects) */
56 FIRST_INTERESTING_FLAG = 0x0100,
58 /** an ice brick that makes tux sliding more than usual */
60 /** a water tile in which tux starts to swim */
62 /** a tile that hurts the player if he touches it */
64 /** for lava: WATER, HURTS, FIRE */
70 WORLDMAP_NORTH = 0x0001,
71 WORLDMAP_SOUTH = 0x0002,
72 WORLDMAP_EAST = 0x0004,
73 WORLDMAP_WEST = 0x0008,
74 WORLDMAP_DIR_MASK = 0x000f,
76 WORLDMAP_STOP = 0x0010,
78 // convenience values ("C" stands for crossroads)
79 WORLDMAP_CNSE = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST,
80 WORLDMAP_CNSW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_WEST,
81 WORLDMAP_CNEW = WORLDMAP_NORTH | WORLDMAP_EAST | WORLDMAP_WEST,
82 WORLDMAP_CSEW = WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST,
83 WORLDMAP_CNSEW = WORLDMAP_NORTH | WORLDMAP_SOUTH | WORLDMAP_EAST | WORLDMAP_WEST
87 ImageSpec(const std::string& newfile, const Rectf& newrect)
88 : file(newfile), rect(newrect)
96 const TileSet& tileset;
97 std::vector<ImageSpec> imagespecs;
98 std::vector<SurfacePtr> images;
99 std::vector<ImageSpec> editor_imagespecs;
100 std::vector<SurfacePtr> editor_images;
105 /** General purpose data attached to a tile (content of a box, type of coin)*/
111 Tile(const TileSet& tileset);
112 Tile(const TileSet& tileset, const std::vector<ImageSpec>& images, const std::vector<ImageSpec>& editor_images,
113 uint32_t attributes, uint32_t data, float fps);
116 /** load Surfaces, if not already loaded */
119 /** Draw a tile on the screen */
120 void draw(DrawingContext& context, const Vector& pos, int z_pos) const;
122 uint32_t getAttributes() const
123 { return attributes; }
128 void print_debug(int id) const;
131 //Correct small oddities in attributes that naive people
132 //might miss (and rebuke them for it)
133 void correct_attributes();
137 Tile& operator=(const Tile&);