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"
30 extern Menu* worldmap_menu;
32 namespace WorldMapNS {
34 enum WorldMapMenuIDs {
56 // Directions in which Tux is allowed to walk from this tile
65 /** Stop on this tile or walk over it? */
68 /** When set automatically turn directions when walked over such a
69 tile (ie. walk smoothly a curve) */
76 typedef std::vector<Tile*> Tiles;
86 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
88 std::string direction_to_string(Direction d);
89 Direction string_to_direction(const std::string& d);
90 Direction reverse_dir(Direction d);
97 Direction back_direction;
100 Surface* largetux_sprite;
101 Surface* firetux_sprite;
102 Surface* smalltux_sprite;
104 Direction input_direction;
107 /** Length by which tux is away from its current tile, length is in
108 input_direction direction */
114 Tux(WorldMap* worldmap_);
117 void draw(DrawingContext& context, const Vector& offset);
118 void action(float elapsed_time);
120 void set_direction(Direction dir);
122 bool is_moving() const { return moving; }
124 Vector get_tile_pos() const { return tile_pos; }
125 void set_tile_pos(Vector p) { tile_pos = p; }
136 Surface* leveldot_green;
137 Surface* leveldot_red;
139 Surface* teleporterdot;
144 std::vector<int> tilemap;
151 TileManager* tile_manager;
158 std::string level_name;
162 /** Optional flags: */
164 /** Check if this level should be vertically flipped */
167 /** Filename of the extro text to show once the level is
168 successfully completed */
169 std::string extro_filename;
171 /** Position to swap to player */
172 int teleport_dest_x, teleport_dest_y;
174 /** Message to show in the Map */
175 std::string map_message;
176 bool passive_message;
178 /** Hide special tile */
181 /** Go to this world */
182 std::string next_worldmap;
184 /** Quit the worldmap */
187 /** If false, disables the auto walking after finishing a level */
190 // Directions which are walkable from this level
196 /** Only applies actions (ie. passive messages) when going to that direction */
197 bool apply_action_north;
198 bool apply_action_east;
199 bool apply_action_south;
200 bool apply_action_west;
203 /** Variables to deal with the passive map messages */
204 Timer passive_message_timer;
205 std::string passive_message;
208 std::string map_filename;
210 typedef std::vector<SpecialTile> SpecialTiles;
211 SpecialTiles special_tiles;
218 std::string savegame_file;
220 void get_level_title(SpecialTile& special_tile);
222 void draw_status(DrawingContext& context);
234 /** Update Tux position */
235 void update(float delta);
237 /** Draw one frame */
238 void draw(DrawingContext& context, const Vector& offset);
240 Vector get_next_tile(Vector pos, Direction direction);
241 Tile* at(Vector pos);
242 WorldMap::SpecialTile* at_special_tile();
244 /** Check if it is possible to walk from \a pos into \a direction,
245 if possible, write the new position to \a new_pos */
246 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
248 /* Save map to slot */
249 void savegame(const std::string& filename);
250 /* Load map from slot */
251 void loadgame(const std::string& filename);
252 /* Load map directly from file */
253 void loadmap(const std::string& filename);
255 const std::string& get_world_title() const
258 const int& get_start_x() const
261 const int& get_start_y() const
265 void on_escape_press();
268 } // namespace WorldMapNS
272 /* Local Variables: */