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"
31 extern Menu* worldmap_menu;
33 namespace WorldMapNS {
35 enum WorldMapMenuIDs {
57 // Directions in which Tux is allowed to walk from this tile
66 /** Stop on this tile or walk over it? */
69 /** When set automatically turn directions when walked over such a
70 tile (ie. walk smoothly a curve) */
77 typedef std::vector<Tile*> Tiles;
87 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
89 std::string direction_to_string(Direction d);
90 Direction string_to_direction(const std::string& d);
91 Direction reverse_dir(Direction d);
98 Direction back_direction;
101 Surface* largetux_sprite;
102 Surface* firetux_sprite;
103 Surface* smalltux_sprite;
105 Direction input_direction;
108 /** Length by which tux is away from its current tile, length is in
109 input_direction direction */
115 Tux(WorldMap* worldmap_);
118 void draw(DrawingContext& context, const Vector& offset);
119 void action(float elapsed_time);
121 void set_direction(Direction dir);
123 bool is_moving() const { return moving; }
125 Vector get_tile_pos() const { return tile_pos; }
126 void set_tile_pos(Vector p) { tile_pos = p; }
137 Surface* leveldot_green;
138 Surface* leveldot_red;
140 Surface* teleporterdot;
145 std::vector<int> tilemap;
152 TileManager* tile_manager;
159 std::string level_name;
163 /** Statistics for level tiles */
164 Statistics statistics;
166 /** Optional flags: */
168 /** Check if this level should be vertically flipped */
171 /** Filename of the extro text to show once the level is
172 successfully completed */
173 std::string extro_filename;
175 /** Position to swap to player */
176 int teleport_dest_x, teleport_dest_y;
178 /** Message to show in the Map */
179 std::string map_message;
180 bool passive_message;
182 /** Hide special tile */
185 /** Go to this world */
186 std::string next_worldmap;
188 /** Quit the worldmap */
191 /** If false, disables the auto walking after finishing a level */
194 // Directions which are walkable from this level
200 /** Only applies actions (ie. passive messages) when going to that direction */
201 bool apply_action_north;
202 bool apply_action_east;
203 bool apply_action_south;
204 bool apply_action_west;
207 /** Variables to deal with the passive map messages */
208 Timer passive_message_timer;
209 std::string passive_message;
212 std::string map_filename;
214 typedef std::vector<SpecialTile> SpecialTiles;
215 SpecialTiles special_tiles;
222 std::string savegame_file;
224 void get_level_title(SpecialTile& special_tile);
226 void draw_status(DrawingContext& context);
228 // to avoid calculating total stats all the time. This way only
229 // when need, it is calculated.
230 Statistics total_stats;
231 void calculate_total_stats();
244 /** Update Tux position */
245 void update(float delta);
247 /** Draw one frame */
248 void draw(DrawingContext& context, const Vector& offset);
250 Vector get_next_tile(Vector pos, Direction direction);
251 Tile* at(Vector pos);
252 WorldMap::SpecialTile* at_special_tile();
254 /** Check if it is possible to walk from \a pos into \a direction,
255 if possible, write the new position to \a new_pos */
256 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
258 /* Save map to slot */
259 void savegame(const std::string& filename);
260 /* Load map from slot */
261 void loadgame(const std::string& filename);
262 /* Load map directly from file */
263 void loadmap(const std::string& filename);
265 const std::string& get_world_title() const
268 const int& get_start_x() const
271 const int& get_start_y() const
275 void on_escape_press();
278 } // namespace WorldMapNS
282 /* Local Variables: */