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
29 namespace WorldMapNS {
39 // Directions in which Tux is allowed to walk from this tile
45 /** Stop on this tile or walk over it? */
48 /** When set automatically turn directions when walked over such a
49 tile (ie. walk smoothly a curve) */
56 typedef std::vector<Tile*> Tiles;
66 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
68 std::string direction_to_string(Direction d);
69 Direction string_to_direction(const std::string& d);
70 Direction reverse_dir(Direction d);
77 Direction back_direction;
80 Surface* largetux_sprite;
81 Surface* firetux_sprite;
82 Surface* smalltux_sprite;
84 Direction input_direction;
87 /** Length by which tux is away from its current tile, length is in
88 input_direction direction */
94 Tux(WorldMap* worldmap_);
97 void draw(const Point& offset);
98 void update(float delta);
100 void set_direction(Direction d) { input_direction = d; }
102 bool is_moving() const { return moving; }
104 Point get_tile_pos() const { return tile_pos; }
105 void set_tile_pos(Point p) { tile_pos = p; }
116 Surface* level_sprite;
117 Surface* leveldot_green;
118 Surface* leveldot_red;
123 std::vector<int> tilemap;
127 TileManager* tile_manager;
138 /** Filename of the extro text to show once the level is
139 successfully completed */
140 std::string extro_filename;
142 // Directions which are walkable from this level
150 typedef std::vector<Level> Levels;
155 Direction input_direction;
159 std::string savegame_file;
161 void get_level_title(Levels::pointer level);
175 /** Update Tux position */
176 void update(float delta);
178 /** Draw one frame */
179 void draw(const Point& offset);
181 Point get_next_tile(Point pos, Direction direction);
183 WorldMap::Level* at_level();
185 /** Check if it is possible to walk from \a pos into \a direction,
186 if possible, write the new position to \a new_pos */
187 bool path_ok(Direction direction, Point pos, Point* new_pos);
189 void savegame(const std::string& filename);
190 void loadgame(const std::string& filename);
192 void on_escape_press();
195 } // namespace WorldMapNS
199 /* Local Variables: */