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 #include "screen/screen.h"
30 namespace WorldMapNS {
40 // Directions in which Tux is allowed to walk from this tile
46 /** Stop on this tile or walk over it? */
49 /** When set automatically turn directions when walked over such a
50 tile (ie. walk smoothly a curve) */
57 typedef std::vector<Tile*> Tiles;
67 enum Direction { D_NONE, D_WEST, D_EAST, D_NORTH, D_SOUTH };
69 std::string direction_to_string(Direction d);
70 Direction string_to_direction(const std::string& d);
71 Direction reverse_dir(Direction d);
78 Direction back_direction;
81 Surface* largetux_sprite;
82 Surface* firetux_sprite;
83 Surface* smalltux_sprite;
85 Direction input_direction;
88 /** Length by which tux is away from its current tile, length is in
89 input_direction direction */
95 Tux(WorldMap* worldmap_);
98 void draw(DrawingContext& context, const Vector& offset);
99 void action(float elapsed_time);
101 void set_direction(Direction d) { input_direction = d; }
103 bool is_moving() const { return moving; }
105 Vector get_tile_pos() const { return tile_pos; }
106 void set_tile_pos(Vector p) { tile_pos = p; }
117 Surface* level_sprite;
118 Surface* leveldot_green;
119 Surface* leveldot_red;
124 std::vector<int> tilemap;
128 TileManager* tile_manager;
139 /** Filename of the extro text to show once the level is
140 successfully completed */
141 std::string extro_filename;
143 // Directions which are walkable from this level
151 typedef std::vector<Level> Levels;
156 Direction input_direction;
160 std::string savegame_file;
162 void get_level_title(Level& level);
164 void draw_status(DrawingContext& context);
176 /** Update Tux position */
177 void update(float delta);
179 /** Draw one frame */
180 void draw(DrawingContext& context, const Vector& offset);
182 Vector get_next_tile(Vector pos, Direction direction);
183 Tile* at(Vector pos);
184 WorldMap::Level* at_level();
186 /** Check if it is possible to walk from \a pos into \a direction,
187 if possible, write the new position to \a new_pos */
188 bool path_ok(Direction direction, Vector pos, Vector* new_pos);
190 void savegame(const std::string& filename);
191 void loadgame(const std::string& filename);
193 void on_escape_press();
196 } // namespace WorldMapNS
200 /* Local Variables: */