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"
30 #include "special/timer.h"
32 extern Menu* worldmap_menu;
34 namespace WorldMapNS {
36 enum WorldMapMenuIDs {
56 void draw(DrawingContext& context, Vector pos);
58 std::vector<Surface*> images;
61 // Directions in which Tux is allowed to walk from this tile
70 /** Stop on this tile or walk over it? */
73 /** When set automatically turn directions when walked over such a
74 tile (ie. walk smoothly a curve) */
81 typedef std::vector<Tile*> Tiles;
91 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
93 std::string direction_to_string(Direction d);
94 Direction string_to_direction(const std::string& d);
95 Direction reverse_dir(Direction d);
102 Direction back_direction;
105 Surface* largetux_sprite;
106 Surface* firetux_sprite;
107 Surface* smalltux_sprite;
109 Direction input_direction;
112 /** Length by which tux is away from its current tile, length is in
113 input_direction direction */
119 Tux(WorldMap* worldmap_);
122 void draw(DrawingContext& context, const Vector& offset);
123 void action(float elapsed_time);
125 void set_direction(Direction dir);
127 bool is_moving() const { return moving; }
129 Vector get_tile_pos() const { return tile_pos; }
130 void set_tile_pos(Vector p) { tile_pos = p; }
141 Surface* leveldot_green;
142 Surface* leveldot_red;
144 Surface* teleporterdot;
149 std::vector<int> tilemap;
156 TileManager* tile_manager;
163 /** Optional flags: */
165 /** Position to swap to player */
166 Vector teleport_dest;
168 /** Message to show in the Map */
169 std::string map_message;
170 bool passive_message;
172 /** Hide special tile */
175 /** Only applies actions (ie. passive messages) when going to that direction */
176 bool apply_action_north;
177 bool apply_action_east;
178 bool apply_action_south;
179 bool apply_action_west;
190 /** Statistics for level tiles */
191 Statistics statistics;
193 /** Optional flags: */
195 /** Check if this level should be vertically flipped */
198 /** Filename of the extro text to show once the level is
199 successfully completed */
200 std::string extro_filename;
202 /** Go to this world */
203 std::string next_worldmap;
205 /** Quit the worldmap */
208 /** If false, disables the auto walking after finishing a level */
211 // Directions which are walkable from this level
218 /** Variables to deal with the passive map messages */
219 Timer passive_message_timer;
220 std::string passive_message;
223 std::string map_filename;
225 typedef std::vector<SpecialTile> SpecialTiles;
226 SpecialTiles special_tiles;
228 typedef std::vector<Level> Levels;
236 std::string savegame_file;
238 void get_level_title(Level& level);
240 void draw_status(DrawingContext& context);
242 // to avoid calculating total stats all the time. This way only
243 // when need, it is calculated.
244 Statistics total_stats;
245 void calculate_total_stats();
260 /** Update Tux position */
261 void update(float delta);
263 /** Draw one frame */
264 void draw(DrawingContext& context, const Vector& offset);
266 Vector get_next_tile(Vector pos, Direction direction);
267 Tile* at(Vector pos);
269 WorldMap::Level* at_level();
270 WorldMap::SpecialTile* at_special_tile();
272 /** Check if it is possible to walk from \a pos into \a direction,
273 if possible, write the new position to \a new_pos */
274 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
276 /* Save map to slot */
277 void savegame(const std::string& filename);
278 /* Load map from slot
279 You should call set_map_filename() before this */
280 void loadgame(const std::string& filename);
281 /* Load map directly from file */
282 void loadmap(const std::string& filename);
284 const std::string& get_world_title() const
287 const int& get_start_x() const
290 const int& get_start_y() const
293 void set_map_filename(std::string filename)
294 { map_filename = filename; }
297 void on_escape_press();
300 } // namespace WorldMapNS
304 /* Local Variables: */