From: Christoph Sommer Date: Tue, 20 Jun 2006 15:51:08 +0000 (+0000) Subject: Added "interactive" Teleporters / X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=2bae88e5e4c711db0e12a1339777e0fb4bba73c5;p=supertux.git Added "interactive" Teleporters / teleporting special-tile objects should now be obsolete SVN-Revision: 3684 --- diff --git a/data/levels/world1/worldmap.stwm b/data/levels/world1/worldmap.stwm index e68742039..c7c0977d0 100644 --- a/data/levels/world1/worldmap.stwm +++ b/data/levels/world1/worldmap.stwm @@ -23,6 +23,16 @@ (x 38) (y 21) ) + (worldmap-spawnpoint + (name "bridge") + (x 8) + (y 15) + ) + (worldmap-spawnpoint + (name "bonus") + (x 1) + (y 26) + ) (level (name "01 - Welcome to Antarctica.stl") (x 22) @@ -172,27 +182,6 @@ (sprite "images/objects/invisible/invisible.sprite") ) (special-tile - (teleport-to-x 9) - (teleport-to-y 15) - (x 16) - (y 25) - (sprite "images/worldmap/common/teleporterdot.sprite") - ) - (special-tile - (teleport-to-x 1) - (teleport-to-y 26) - (invisible-tile #t) - (x 29) - (y 18) - ) - (special-tile - (teleport-to-x 22) - (teleport-to-y 4) - (x 1) - (y 26) - (sprite "images/worldmap/common/teleporterdot.sprite") - ) - (special-tile (teleport-to-x 0) (teleport-to-y 0) (map-message (_ "You found a secret area!")) @@ -222,6 +211,26 @@ (x 39) (y 21) ) + (teleporter + (spawnpoint "bridge") + (interactive #t) + (x 1) + (y 26) + (sprite "images/worldmap/common/teleporterdot.sprite") + ) + (teleporter + (spawnpoint "bonus") + (interactive #t) + (x 29) + (y 18) + ) + (teleporter + (spawnpoint "bridge") + (interactive #t) + (x 16) + (y 25) + (sprite "images/worldmap/common/teleporterdot.sprite") + ) ) (tileset "images/worldmap.strf") ) diff --git a/src/worldmap/tux.cpp b/src/worldmap/tux.cpp index 6964c6631..0e8e2a707 100644 --- a/src/worldmap/tux.cpp +++ b/src/worldmap/tux.cpp @@ -173,15 +173,6 @@ Tux::tryContinueWalking(float elapsed_time) sprite_change->in_stay_action = false; } - Teleporter* teleporter = worldmap->at_teleporter(tile_pos); - if (teleporter) { - if (teleporter->worldmap != "") { - worldmap->change(teleporter->worldmap, teleporter->spawnpoint); - } else { - worldmap->move_to_spawnpoint(teleporter->spawnpoint); - } - } - // if this is a special_tile with passive_message, display it SpecialTile* special_tile = worldmap->at_special_tile(); if(special_tile) @@ -208,11 +199,15 @@ Tux::tryContinueWalking(float elapsed_time) } } - // stop if we reached a level, a WORLDMAP_STOP tile or a special tile without a passive_message + // check if we are at a Teleporter + Teleporter* teleporter = worldmap->at_teleporter(tile_pos); + + // stop if we reached a level, a WORLDMAP_STOP tile, a teleporter or a special tile without a passive_message if ((worldmap->at_level()) || (worldmap->at(tile_pos)->getData() & Tile::WORLDMAP_STOP) || (special_tile && !special_tile->passive_message - && special_tile->script == "")) { + && special_tile->script == "") + || (teleporter)) { if(special_tile && !special_tile->map_message.empty() && !special_tile->passive_message) worldmap->passive_message_timer.start(0); diff --git a/src/worldmap/worldmap.cpp b/src/worldmap/worldmap.cpp index ba81b1e6c..6c12e6b13 100644 --- a/src/worldmap/worldmap.cpp +++ b/src/worldmap/worldmap.cpp @@ -524,7 +524,20 @@ WorldMap::update(float delta) enter_level = true; if(main_controller->pressed(Controller::PAUSE_MENU)) on_escape_press(); - + + // check for teleporters + Teleporter* teleporter = at_teleporter(tux->get_tile_pos()); + if (teleporter && ((!teleporter->interactive) || (enter_level && (!tux->is_moving())))) { + enter_level = false; + if (teleporter->worldmap != "") { + change(teleporter->worldmap, teleporter->spawnpoint); + } else { + sound_manager->play("sounds/warp.wav"); + tux->back_direction = D_NONE; + move_to_spawnpoint(teleporter->spawnpoint); + } + } + if (enter_level && !tux->is_moving()) { /* Check special tile action */ @@ -710,8 +723,11 @@ WorldMap::setup() current_ = this; load_state(); - // if force_spawnpoint was set, move Tux there - if (force_spawnpoint != "") move_to_spawnpoint(force_spawnpoint); + // if force_spawnpoint was set, move Tux there, then clear force_spawnpoint + if (force_spawnpoint != "") { + move_to_spawnpoint(force_spawnpoint); + force_spawnpoint = ""; + } // register worldmap_table as worldmap in scripting using namespace Scripting;