X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fobject%2Fpath_walker.hpp;h=f3bdf9e6e94818cfe6a4e8c5e3e94052feb39448;hb=ed161bf9da56b598f3db3637c6017fa22e9ab0d7;hp=016de8a3f4b255881dcf8a9bee9f8242ce80858b;hpb=1d63ad0dfe0eedf89191627be00b2b3b1215c311;p=supertux.git diff --git a/src/object/path_walker.hpp b/src/object/path_walker.hpp index 016de8a3f..f3bdf9e6e 100644 --- a/src/object/path_walker.hpp +++ b/src/object/path_walker.hpp @@ -1,8 +1,7 @@ -// $Id: path.hpp 3114 2006-03-23 23:47:04Z sommer $ -// -// SuperTux Path -// Copyright (C) 2005 Philipp -// Copyright (C) 2006 Christoph Sommer +// $Id$ +// +// SuperTux +// Copyright (C) 2006 Matthias Braun // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License @@ -13,11 +12,11 @@ // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. -// +// // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software -// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA -// 02111-1307, USA. +// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + #ifndef __PATH_WALKER_HPP__ #define __PATH_WALKER_HPP__ @@ -33,7 +32,7 @@ class PathWalker { public: - PathWalker(const Path* path); + PathWalker(const Path* path, bool running = true); virtual ~PathWalker(); /** @@ -42,19 +41,40 @@ public: */ virtual Vector advance(float elapsed_time); + /** advance until at given node, then stop */ + void goto_node(int node_no); + + /** start advancing automatically */ + void start_moving(); + + /** stop advancing automatically */ + void stop_moving(); + + const Path* path; + private: void advance_node(); void goback_node(); - - const Path* path; + + /** + * set to false to immediately stop advancing + */ + bool running; size_t current_node_nr; size_t next_node_nr; - Vector last_pos; + /** + * stop advancing automatically when this node is reached + */ + int stop_at_node_nr; - /** the time we already spend in the current node */ + /** + * the position between the current node and the next node as fraction + * between 0 and 1 + */ float node_time; + float node_mult; float walking_speed; };