18 #ifndef HEADER_SUPERTUX_WORLDMAP_WORLDMAP_HPP 19 #define HEADER_SUPERTUX_WORLDMAP_WORLDMAP_HPP 23 #include "math/vector.hpp" 24 #include "supertux/game_object_manager.hpp" 25 #include "squirrel/squirrel_environment.hpp" 26 #include "supertux/statistics.hpp" 27 #include "supertux/timer.hpp" 28 #include "util/currenton.hpp" 29 #include "worldmap/direction.hpp" 30 #include "worldmap/spawn_point.hpp" 57 static Color level_title_color;
58 static Color message_color;
59 static Color teleporter_message_color;
62 WorldMap(
const std::string& filename,
Savegame& savegame,
const std::string& force_spawnpoint =
"");
65 void finish_construction();
71 void update(
float dt_sec);
73 void process_input(
const Controller& controller);
75 Vector get_next_tile(
const Vector& pos,
const Direction& direction)
const;
87 size_t level_count()
const;
88 size_t solved_level_count()
const;
94 Savegame& get_savegame()
const {
return m_savegame; }
100 for (
const auto& sp : m_spawn_points) {
101 if (sp->get_name() == spawnpoint_name) {
123 const std::string& get_title()
const {
return m_name; }
127 void change(
const std::string& filename,
const std::string& force_spawnpoint=
"");
133 void move_to_spawnpoint(
const std::string& spawnpoint,
bool pan =
false,
bool main_as_default =
true);
141 m_initial_fade_tilemap = tilemap_name;
142 m_fade_direction = direction;
148 m_force_spawnpoint = spawnpoint_name;
152 m_main_is_default =
false;
155 void run_script(
const std::string& script,
const std::string& sourcename);
157 void set_passive_message(
const std::string& message,
float time);
159 Camera& get_camera()
const {
return *m_camera; }
168 void load(
const std::string& filename);
169 void on_escape_press();
172 std::unique_ptr<SquirrelEnvironment> m_squirrel_environment;
173 std::unique_ptr<Camera> m_camera;
184 std::string m_init_script;
187 Timer m_passive_message_timer;
188 std::string m_passive_message;
190 std::string m_map_filename;
191 std::string m_levels_path;
193 std::vector<std::unique_ptr<SpawnPoint> > m_spawn_points;
195 std::string m_force_spawnpoint;
196 bool m_main_is_default;
197 std::string m_initial_fade_tilemap;
198 int m_fade_direction;
This class keeps player status between different game sessions (for example when switching maps in th...
Definition: player_status.hpp:38
Definition: controller.hpp:56
Definition: spawn_point.hpp:29
int tile_data_at(const Vector &pos) const
returns a bitfield representing the union of all Tile::WORLDMAP_XXX values of all solid tiles at the ...
Definition: worldmap.cpp:418
Simple two dimensional vector.
Definition: vector.hpp:24
Definition: sprite.hpp:25
Definition: worldmap_state.hpp:25
SpawnPoint * get_spawnpoint_by_name(const std::string &spawnpoint_name) const
Get a spawnpoint by its name.
Definition: worldmap.hpp:98
Definition: game_object_manager.hpp:34
void set_initial_fade_tilemap(const std::string &tilemap_name, int direction)
Sets the name of the tilemap that should fade when worldmap is set up.
Definition: worldmap.hpp:139
void change(const std::string &filename, const std::string &force_spawnpoint="")
switch to another worldmap.
Definition: worldmap.cpp:160
The SquirrelEnvironment contains the environment in which a script is executed, meaning a root table ...
Definition: squirrel_environment.hpp:35
virtual bool before_object_add(GameObject &object) override
Hook that is called before an object is added to the vector.
Definition: worldmap.cpp:127
Definition: camera.hpp:25
Definition: object_settings.hpp:28
int available_directions_at(const Vector &pos) const
gets a bitfield of Tile::WORLDMAP_NORTH | Tile::WORLDMAP_WEST | ...
Definition: worldmap.cpp:432
Definition: level_tile.hpp:30
A 'Currenton' allows access to the currently active instance of a class via the static current() func...
Definition: currenton.hpp:30
void finished_level(Level *level)
gets called from the GameSession when a level has been successfully finished
Definition: worldmap.cpp:244
void save_state()
Save worldmap state to squirrel state table.
Definition: worldmap.cpp:697
void set_initial_spawnpoint(const std::string &spawnpoint_name)
Sets the initial spawnpoint on worldmap setup.
Definition: worldmap.hpp:146
Represents a collection of Sectors running in a single GameSession.
Definition: level.hpp:29
Base class for all the things that make up Levels' Sectors.
Definition: game_object.hpp:46
void load_state()
Load worldmap state from squirrel state table.
Definition: worldmap.cpp:690
Definition: savegame.hpp:66
void move_to_spawnpoint(const std::string &spawnpoint, bool pan=false, bool main_as_default=true)
Moves Tux to the given spawnpoint.
Definition: worldmap.cpp:140
Definition: worldmap_parser.hpp:28
virtual void before_object_remove(GameObject &object) override
Hook that is called before an object is removed from the vector.
Definition: worldmap.cpp:134
Definition: special_tile.hpp:31
Definition: sprite_change.hpp:32
Definition: teleporter.hpp:30
void set_levels_solved(bool solved, bool perfect)
Mark all levels as solved or unsolved.
Definition: worldmap.cpp:661
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
This class is responsible for drawing the level tiles.
Definition: tilemap.hpp:39
Definition: camera.hpp:36
Definition: tile_set.hpp:42
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
bool path_ok(const Direction &direction, const Vector &pos, Vector *new_pos) const
Check if it is possible to walk from pos into direction, if possible, write the new position to new_p...
Definition: worldmap.cpp:204
Definition: worldmap.hpp:50