Update of /cvsroot/super-tux/supertux/src
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1889
Modified Files:
worldmap.cpp worldmap.h
Log Message:
- added automatic walking on worldmap
Index: worldmap.cpp
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/worldmap.cpp,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -d -r1.53 -r1.54
--- worldmap.cpp 26 Apr 2004 12:21:23 -0000 1.53
+++ worldmap.cpp 26 Apr 2004 12:41:50 -0000 1.54
@@ -110,6 +110,7 @@
tile->south = true;
tile->west = true;
tile->stop = true;
+ tile->auto_walk = false;
LispReader reader(lisp_cdr(element));
reader.read_int("id", &id);
@@ -118,6 +119,7 @@
reader.read_bool("west", &tile->west);
reader.read_bool("east", &tile->east);
reader.read_bool("stop", &tile->stop);
+ reader.read_bool("auto-walk", &tile->auto_walk);
reader.read_string("image", &filename);
tile->sprite = new Surface(
@@ -265,6 +267,33 @@
}
else
{
+ if (worldmap->at(tile_pos)->auto_walk)
+ { // Turn to a new direction
+ Tile* tile = worldmap->at(tile_pos);
+ Direction dir = NONE;
+
+ if (tile->north && back_direction != NORTH)
+ dir = NORTH;
+ else if (tile->south && back_direction != SOUTH)
+ dir = SOUTH;
+ else if (tile->east && back_direction != EAST)
+ dir = EAST;
+ else if (tile->west && back_direction != WEST)
+ dir = WEST;
+
+ if (dir != NONE)
+ {
+ direction = dir;
+ back_direction = reverse_dir(direction);
+ }
+ else
+ {
+ // Should never be reached if tiledata is good
+ stop();
+ return;
+ }
+ }
+
// Walk automatically to the next tile
Point next_tile;
if (worldmap->path_ok(direction, tile_pos, &next_tile))
Index: worldmap.h
===================================================================
RCS file: /cvsroot/super-tux/supertux/src/worldmap.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- worldmap.h 26 Apr 2004 12:19:23 -0000 1.24
+++ worldmap.h 26 Apr 2004 12:41:50 -0000 1.25
@@ -63,8 +63,9 @@
/** Stop on this tile or walk over it? */
bool stop;
- /** direction in which to automatically turn when walked on such a tile */
- Direction auto_walk;
+ /** When set automatically turn directions when walked over such a
+ tile (ie. walk smoothly a curve) */
+ bool auto_walk;
};
class TileManager
|