msg_info("You are at x " << tux.get_pos().x << ", y " << tux.get_pos().y);
return true;
}
-#if 0
- if(command == "grid")) {
- // toggle debug grid
- debug_grid = !debug_grid;
- return true;
- }
-#endif
if (command == "gotoend") {
// goes to the end of the level
tux.move(Vector(
return true;
}
if (command == "flip") {
- FlipLevelTransformer flip_transformer;
+ FlipLevelTransformer flip_transformer;
flip_transformer.transform(GameSession::current()->get_current_level());
return true;
}
if (command == "finish") {
- if(WorldMap::current() != NULL) {
- WorldMap::current()->finished_level(levelfile);
- }
-
+ finish(true);
return true;
}
if (command == "camera") {
/** displays a text file and scrolls it over the screen */
void display_text_file(const std::string& filename);
+
/**
* Suspends the script execution for the specified number of seconds
*/
void wait(float seconds) __suspend;
+
/** translates a give text into the users language (by looking it up in the .po
* files)
*/
std::string translate(const std::string& text);
+
/** load a script file and executes it
* This is typically used to import functions from external files.
*/
void import(HSQUIRRELVM v, const std::string& filename);
+
/** add a key to the inventory
*/
void add_key(int new_key);
#include "worldmap.hpp"
#include "resources.hpp"
#include "misc.hpp"
+#include "msg.hpp"
#include "player_status.hpp"
#include "textscroller.hpp"
#include "main.hpp"
parse_level_tile(iter.lisp());
} else if(iter.item() == "special-tile") {
parse_special_tile(iter.lisp());
+ } else if(iter.item() == "name") {
+ // skip
} else {
msg_warning("Unknown token '" << iter.item() << "' in worldmap");
}
tux->set_direction(dir);
}
}
+
+ if (level->extro_script != "") {
+ try {
+ std::auto_ptr<ScriptInterpreter> interpreter
+ (new ScriptInterpreter(levels_path));
+ std::istringstream in(level->extro_script);
+ interpreter->run_script(in, "level-extro-script");
+ add_object(interpreter.release());
+ } catch(std::exception& e) {
+ msg_fatal("Couldn't run level-extro-script:" << e.what());
+ }
+ }
+
+ if (!level->next_worldmap.empty()) {
+ // Load given worldmap
+ loadmap(level->next_worldmap);
+ }
+
+ if (level->quit_worldmap)
+ main_loop->exit_screen();
}
void
}
/* Check level action */
- bool level_finished = true;
Level* level = at_level();
if (!level) {
msg_warning("No level to enter at: "
return;
}
- if (level->pos == tux->get_tile_pos())
- {
- // do a shriking fade to the level
- shrink_fade(Vector((level->pos.x*32 + 16 + offset.x),
- (level->pos.y*32 + 16 + offset.y)), 500);
+ if (level->pos == tux->get_tile_pos()) {
+ // do a shriking fade to the level
+ shrink_fade(Vector((level->pos.x*32 + 16 + offset.x),
+ (level->pos.y*32 + 16 + offset.y)), 500);
+ try {
GameSession *session =
- new GameSession(levels_path + level->name,
- ST_GL_LOAD_LEVEL_FILE, &level->statistics);
+ new GameSession(levels_path + level->name,
+ ST_GL_LOAD_LEVEL_FILE, &level->statistics);
main_loop->push_screen(session);
+ } catch(std::exception& e) {
+ msg_fatal("Couldn't load level: " << e.what());
}
- /* The porpose of the next checking is that if the player lost
- the level (in case there is one), don't show anything */
- if(level_finished) {
- if (level->extro_script != "") {
- try {
- std::auto_ptr<ScriptInterpreter> interpreter
- (new ScriptInterpreter(levels_path));
- std::istringstream in(level->extro_script);
- interpreter->run_script(in, "level-extro-script");
- add_object(interpreter.release());
- } catch(std::exception& e) {
- msg_warning("Couldn't run level-extro-script:" << e.what());
- }
- }
-
- if (!level->next_worldmap.empty())
- {
- // Load given worldmap
- loadmap(level->next_worldmap);
- }
- if (level->quit_worldmap)
- main_loop->exit_screen();
- }
+ }
}
else
{