4 // Copyright (C) 2004 Tobias Glaesser <tobi.web@gmx.de>
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.
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.
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
29 #include "lispreader.h"
44 std::vector<Surface*> images;
45 std::vector<Surface*> editor_images;
47 std::vector<std::string> filenames;
48 std::vector<std::string> editor_filenames;
50 /** solid tile that is indestructable by Tux */
53 /** uni-directional solid tile */
56 /** a brick that can be destroyed by jumping under it */
65 /** spike - kills player on contact */
68 /** Bonusbox, content is stored in \a data */
71 /** Tile is a distro/coin */
75 /** the level should be finished when touching a goaltile.
76 * if data is 0 then the endsequence should be triggered, if data is 1
77 * then we can finish the level instantly.
81 /** General purpose data attached to a tile (content of a box, type of coin) */
84 /** Id of the tile that is going to replace this tile once it has
85 been collected or jumped at */
90 /** Draw a tile on the screen: */
91 static void draw(float x, float y, unsigned int c, Uint8 alpha = 255);
92 static void draw_stretched(float x, float y, int w, int h, unsigned int c, Uint8 alpha = 255);
94 static void draw(const Vector& pos, unsigned int c, Uint8 alpha = 255)
96 draw(pos.x, pos.y, c, alpha);
102 friend bool operator<(const TileGroup& lhs, const TileGroup& rhs)
103 { return lhs.name < rhs.name; };
104 friend bool operator>(const TileGroup& lhs, const TileGroup& rhs)
105 { return lhs.name > rhs.name; };
108 std::vector<int> tiles;
117 std::vector<Tile*> tiles;
118 static TileManager* instance_ ;
119 static std::set<TileGroup>* tilegroups_;
120 void load_tileset(std::string filename);
122 std::string current_tileset;
125 static TileManager* instance() { return instance_ ? instance_ : instance_ = new TileManager(); }
126 static void destroy_instance() { delete instance_; instance_ = 0; }
128 static std::set<TileGroup>* tilegroups() { if(!instance_) { instance_ = new TileManager(); } return tilegroups_ ? tilegroups_ : tilegroups_ = new std::set<TileGroup>; }
129 Tile* get(unsigned int id) {
130 if(id < tiles.size())
136 // Never return 0, but return the 0th tile instead so that
137 // user code doesn't have to check for NULL pointers all over