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 {
47 // Directions in which Tux is allowed to walk from this tile
53 /** Stop on this tile or walk over it? */
56 /** When set automatically turn directions when walked over such a
57 tile (ie. walk smoothly a curve) */
64 typedef std::vector<Tile*> Tiles;
74 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
76 std::string direction_to_string(Direction d);
77 Direction string_to_direction(const std::string& d);
78 Direction reverse_dir(Direction d);
85 Direction back_direction;
88 Surface* largetux_sprite;
89 Surface* firetux_sprite;
90 Surface* smalltux_sprite;
92 Direction input_direction;
95 /** Length by which tux is away from its current tile, length is in
96 input_direction direction */
102 Tux(WorldMap* worldmap_);
105 void draw(DrawingContext& context, const Vector& offset);
106 void action(float elapsed_time);
108 void set_direction(Direction d) { input_direction = d; }
110 bool is_moving() const { return moving; }
112 Vector get_tile_pos() const { return tile_pos; }
113 void set_tile_pos(Vector p) { tile_pos = p; }
124 Surface* level_sprite;
125 Surface* leveldot_green;
126 Surface* leveldot_red;
131 std::vector<int> tilemap;
138 TileManager* tile_manager;
149 /** Optional flags: */
151 /** Check if this level should be vertically flipped */
154 /** Filename of the extro text to show once the level is
155 successfully completed */
156 std::string extro_filename;
158 /** Position to swap player */
161 /** Message to show in the Map */
162 std::string display_map_message;
164 /** Go to this world */
165 std::string next_worldmap;
167 /** Quit the worldmap */
170 /** If false, disables the auto walking after finishing a level */
173 // Directions which are walkable from this level
181 std::string map_filename;
183 typedef std::vector<Level> Levels;
188 Direction input_direction;
192 std::string savegame_file;
194 void get_level_title(Level& level);
196 void draw_status(DrawingContext& context);
208 /** Update Tux position */
209 void update(float delta);
211 /** Draw one frame */
212 void draw(DrawingContext& context, const Vector& offset);
214 Vector get_next_tile(Vector pos, Direction direction);
215 Tile* at(Vector pos);
216 WorldMap::Level* at_level();
218 /** Check if it is possible to walk from \a pos into \a direction,
219 if possible, write the new position to \a new_pos */
220 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
222 /* Save map to slot */
223 void savegame(const std::string& filename);
224 /* Load map from slot */
225 void loadgame(const std::string& filename);
226 /* Load map directly from file */
227 void loadmap(const std::string& filename);
229 const std::string& get_world_title() const
232 const int& get_start_x() const
235 const int& get_start_y() const
239 void on_escape_press();
242 } // namespace WorldMapNS
246 /* Local Variables: */