4 // Copyright (C) 2004 Ingo Ruhnke <grumbel@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 02111-1307, USA.
20 #ifndef SUPERTUX_WORLDMAP_H
21 #define SUPERTUX_WORLDMAP_H
26 #include "math/vector.h"
27 #include "audio/musicref.h"
28 #include "video/screen.h"
29 #include "statistics.h"
36 extern Menu* worldmap_menu;
38 namespace WorldMapNS {
40 enum WorldMapMenuIDs {
60 void draw(DrawingContext& context, Vector pos);
62 std::vector<Surface*> images;
65 // Directions in which Tux is allowed to walk from this tile
74 /** Stop on this tile or walk over it? */
77 /** When set automatically turn directions when walked over such a
78 tile (ie. walk smoothly a curve) */
85 typedef std::vector<Tile*> Tiles;
95 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
97 std::string direction_to_string(Direction d);
98 Direction string_to_direction(const std::string& d);
99 Direction reverse_dir(Direction d);
106 Direction back_direction;
109 Surface* largetux_sprite;
110 Surface* firetux_sprite;
111 Surface* smalltux_sprite;
113 Direction input_direction;
116 /** Length by which tux is away from its current tile, length is in
117 input_direction direction */
123 Tux(WorldMap* worldmap_);
126 void draw(DrawingContext& context, const Vector& offset);
127 void action(float elapsed_time);
129 void set_direction(Direction dir);
131 bool is_moving() const { return moving; }
133 Vector get_tile_pos() const { return tile_pos; }
134 void set_tile_pos(Vector p) { tile_pos = p; }
145 Surface* leveldot_green;
146 Surface* leveldot_red;
148 Surface* teleporterdot;
153 std::vector<int> tilemap;
160 TileManager* tile_manager;
167 /** Optional flags: */
169 /** Position to swap to player */
170 Vector teleport_dest;
172 /** Message to show in the Map */
173 std::string map_message;
174 bool passive_message;
176 /** Hide special tile */
179 /** Only applies actions (ie. passive messages) when going to that direction */
180 bool apply_action_north;
181 bool apply_action_east;
182 bool apply_action_south;
183 bool apply_action_west;
194 /** Statistics for level tiles */
195 Statistics statistics;
197 /** Optional flags: */
199 /** Check if this level should be vertically flipped */
202 /** Filename of the extro text to show once the level is
203 successfully completed */
204 std::string extro_filename;
206 /** Go to this world */
207 std::string next_worldmap;
209 /** Quit the worldmap */
212 /** If false, disables the auto walking after finishing a level */
215 // Directions which are walkable from this level
222 /** Variables to deal with the passive map messages */
223 Timer2 passive_message_timer;
224 std::string passive_message;
227 std::string map_filename;
229 typedef std::vector<SpecialTile> SpecialTiles;
230 SpecialTiles special_tiles;
232 typedef std::vector<Level> Levels;
240 std::string savegame_file;
242 void get_level_title(Level& level);
244 void draw_status(DrawingContext& context);
246 // to avoid calculating total stats all the time. This way only
247 // when need, it is calculated.
248 Statistics total_stats;
249 void calculate_total_stats();
264 /** Update Tux position */
265 void update(float delta);
267 /** Draw one frame */
268 void draw(DrawingContext& context, const Vector& offset);
270 Vector get_next_tile(Vector pos, Direction direction);
271 Tile* at(Vector pos);
273 WorldMap::Level* at_level();
274 WorldMap::SpecialTile* at_special_tile();
276 /** Check if it is possible to walk from \a pos into \a direction,
277 if possible, write the new position to \a new_pos */
278 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
280 /* Save map to slot */
281 void savegame(const std::string& filename);
282 /* Load map from slot
283 You should call set_map_filename() before this */
284 void loadgame(const std::string& filename);
285 /* Load map directly from file */
286 void loadmap(const std::string& filename);
288 const std::string& get_world_title() const
291 const int& get_start_x() const
294 const int& get_start_y() const
297 void set_map_filename(std::string filename)
298 { map_filename = filename; }
301 void on_escape_press();
304 } // namespace WorldMapNS
308 /* Local Variables: */