Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2204/src
Modified Files:
Tag: supertux_0_1_1_branch
worldmap.cpp worldmap.h
Log Message:
hacked in a very simple but working teleporter,
"That's-really-all-I'm-asking-for-edition" :-)
anyone who is more into the code than i am, please revise!
Index: worldmap.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v
retrieving revision 1.68.2.12
retrieving revision 1.68.2.13
diff -u -d -r1.68.2.12 -r1.68.2.13
--- worldmap.cpp 31 Jul 2004 10:39:50 -0000 1.68.2.12
+++ worldmap.cpp 10 Aug 2004 21:18:11 -0000 1.68.2.13
@@ -312,7 +312,7 @@
}
Tile* cur_tile = worldmap->at(tile_pos);
- if (cur_tile->stop || (level && !level->name.empty()))
+ if (cur_tile->stop || (level && !level->name.empty()) || (level && level->is_teleporter))
{
stop();
}
@@ -387,6 +387,7 @@
level_sprite = new Surface(datadir + "/images/worldmap/levelmarker.png", USE_ALPHA);
leveldot_green = new Surface(datadir + "/images/worldmap/leveldot_green.png", USE_ALPHA);
leveldot_red = new Surface(datadir + "/images/worldmap/leveldot_red.png", USE_ALPHA);
+ leveldot_teleporter = new Surface(datadir + "/images/worldmap/teleporter.png", USE_ALPHA);
map_file = datadir + "/levels/default/worldmap.stwm";
@@ -405,6 +406,7 @@
delete level_sprite;
delete leveldot_green;
delete leveldot_red;
+ delete leveldot_teleporter;
}
void
@@ -471,8 +473,14 @@
reader.read_bool("auto-path", &level.auto_path);
level.passive_message = true;
reader.read_bool("passive-message", &level.passive_message);
-
- level.apply_action_north = level.apply_action_south =
+
+ level.is_teleporter = false;
+ reader.read_bool("teleporter", &level.is_teleporter);
+ reader.read_int("dest_x", &level.destination_x);
+ reader.read_int("dest_y", &level.destination_y);
+ reader.read_string("teleport-message", &level.teleport_message);
+
+ level.apply_action_north = level.apply_action_south =
level.apply_action_east = level.apply_action_west = true;
reader.read_bool("apply-action-up", &level.apply_action_north);
reader.read_bool("apply-action-down", &level.apply_action_south);
@@ -785,7 +793,17 @@
return;
}
}
- else
+ else if (level && level->is_teleporter) {
+ if (level->x == tux->get_tile_pos().x &&
+ level->y == tux->get_tile_pos().y)
+ {
+ Point p;
+ p.x = level->destination_x;
+ p.y = level->destination_y;
+ tux->set_tile_pos(p);
+ }
+ }
+ else
{
std::cout << "Nothing to enter at: "
<< tux->get_tile_pos().x << ", " << tux->get_tile_pos().y << std::endl;
@@ -858,10 +876,15 @@
for(Levels::iterator i = levels.begin(); i != levels.end(); ++i)
{
- if(i->name.empty())
- continue;
+ if(i->name.empty()) {
+ if (i->is_teleporter) {
+ leveldot_teleporter->draw(i->x*32 + offset.x,
+ i->y*32 + offset.y);
+ }
+ else continue;
+ }
- if (i->solved)
+ else if (i->solved)
leveldot_green->draw(i->x*32 + offset.x,
i->y*32 + offset.y);
else
@@ -909,6 +932,10 @@
{
white_text->draw_align(i->title.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM);
}
+ else if (i->is_teleporter) {
+ if(!i->teleport_message.empty())
+ gold_text->draw_align(i->teleport_message.c_str(), screen->w/2, screen->h, A_HMIDDLE, A_BOTTOM);
+ }
/* Display a message in the map, if any as been selected */
if(!i->display_map_message.empty() && !i->passive_message)
Index: worldmap.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v
retrieving revision 1.28.2.10
retrieving revision 1.28.2.11
diff -u -d -r1.28.2.10 -r1.28.2.11
--- worldmap.h 31 Jul 2004 10:39:50 -0000 1.28.2.10
+++ worldmap.h 10 Aug 2004 21:18:11 -0000 1.28.2.11
@@ -146,6 +146,7 @@
Surface* level_sprite;
Surface* leveldot_green;
Surface* leveldot_red;
+ Surface* leveldot_teleporter;
std::string name;
std::string music;
@@ -175,6 +176,12 @@
/** Message to show in the Map during a certain time */
std::string display_map_message;
bool passive_message;
+
+ /** Teleporters */
+ bool is_teleporter;
+ int destination_x;
+ int destination_y;
+ std::string teleport_message;
/** If false, disables the auto walking after finishing a level */
bool auto_path;
|