X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Fpath_walker.hpp;h=2574b07b00c630160a1fcf704b1f5239db2d37b2;hb=64842a0700a2ee8a3d2d61ad2685217f5060985a;hp=44d947adbda86a791456baed5759fa1170594411;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/object/path_walker.hpp b/src/object/path_walker.hpp index 44d947adb..2574b07b0 100644 --- a/src/object/path_walker.hpp +++ b/src/object/path_walker.hpp @@ -1,12 +1,10 @@ -// $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 -// as published by the Free Software Foundation; either version 2 -// of the License, or (at your option) any later version. +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -14,17 +12,14 @@ // 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. +// along with this program. If not, see . + +#ifndef HEADER_SUPERTUX_OBJECT_PATH_WALKER_HPP +#define HEADER_SUPERTUX_OBJECT_PATH_WALKER_HPP -#ifndef __PATH_WALKER_HPP__ -#define __PATH_WALKER_HPP__ +#include -#include "path.hpp" -#include "math/vector.hpp" -#include "game_object.hpp" -#include "lisp/lisp.hpp" -#include "serializable.hpp" +#include "object/path.hpp" /** * A walker that travels along a path @@ -32,25 +27,49 @@ class PathWalker { public: - PathWalker(const Path* path); + PathWalker(const Path* path, bool running = true); virtual ~PathWalker(); /** - * advanves the path walker on the path and returns the position delta - * to the last position + * advances the path walker on the path and returns its new position */ virtual Vector advance(float elapsed_time); + /** current position of path walker */ + Vector get_pos(); + + /** 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(); + + /** returns true if PathWalker is currently moving */ + bool is_moving() { + return running; + } + + 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 position between the current node and the next node as fraction @@ -60,6 +79,12 @@ private: float node_mult; float walking_speed; + +private: + PathWalker(const PathWalker&); + PathWalker& operator=(const PathWalker&); }; #endif + +/* EOF */