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
28 namespace WorldMapNS {
32 Point() : x(0), y(0) {}
34 Point(const Point& pos)
35 : x(pos.x), y(pos.y) {}
37 Point& operator=(const Point& pos)
57 // Directions in which Tux is allowed to walk from this tile
63 /** Stop on this tile or walk over it? */
70 typedef std::vector<Tile*> Tiles;
80 enum Direction { NONE, WEST, EAST, NORTH, SOUTH };
82 std::string direction_to_string(Direction d);
83 Direction string_to_direction(const std::string& d);
84 Direction reverse_dir(Direction d);
91 Direction back_direction;
96 Direction input_direction;
99 /** Length by which tux is away from its current tile, length is in
100 input_direction direction */
106 Tux(WorldMap* worldmap_);
109 void draw(const Point& offset);
110 void update(float delta);
112 void set_direction(Direction d) { input_direction = d; }
114 bool is_moving() const { return moving; }
116 Point get_tile_pos() const { return tile_pos; }
117 void set_tile_pos(Point p) { tile_pos = p; }
128 Surface* level_sprite;
129 Surface* leveldot_green;
130 Surface* leveldot_red;
135 std::vector<int> tilemap;
139 TileManager* tile_manager;
150 // Directions which are walkable from this level
158 typedef std::vector<Level> Levels;
163 Direction input_direction;
167 std::string savegame_file;
169 void get_level_title(Levels::pointer level);
183 /** Update Tux position */
186 /** Draw one frame */
187 void draw(const Point& offset);
189 Point get_next_tile(Point pos, Direction direction);
191 WorldMap::Level* at_level();
193 /** Check if it is possible to walk from \a pos into \a direction,
194 if possible, write the new position to \a new_pos */
195 bool path_ok(Direction direction, Point pos, Point* new_pos);
197 void savegame(const std::string& filename);
198 void loadgame(const std::string& filename);
200 void on_escape_press();
203 } // namespace WorldMapNS
207 /* Local Variables: */