X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fobject%2Fpath_walker.cpp;h=3df9ed03a4f15b30478894ccff2bf11a90b8ae13;hb=b88dc6c0a778a019bf0b1f28c2cc9d624d9bbdbd;hp=0c8ae2599ee8fff40bca5ecbb7773bcfd66e4501;hpb=a113d3bd1feddd510e3b2852b0d42522735eee40;p=supertux.git diff --git a/src/object/path_walker.cpp b/src/object/path_walker.cpp index 0c8ae2599..3df9ed03a 100644 --- a/src/object/path_walker.cpp +++ b/src/object/path_walker.cpp @@ -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,18 +12,22 @@ // 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 . -#include +#include "object/path_walker.hpp" #include #include -#include "path_walker.hpp" -PathWalker::PathWalker(const Path* path, bool running) - : path(path), running(running), current_node_nr(0), next_node_nr(0), stop_at_node_nr(running?-1:0), node_time(0), - walking_speed(1.0) +PathWalker::PathWalker(const Path* path, bool running) : + path(path), + running(running), + current_node_nr(0), + next_node_nr(0), + stop_at_node_nr(running?-1:0), + node_time(0), + node_mult(), + walking_speed(1.0) { node_mult = 1 / path->nodes[0].time; next_node_nr = path->nodes.size() > 1 ? 1 : 0; @@ -63,9 +65,16 @@ PathWalker::advance(float elapsed_time) } } - const Path::Node* next_node = & (path->nodes[next_node_nr]); node_time += elapsed_time * node_mult; + return get_pos(); +} + +Vector +PathWalker::get_pos() +{ + const Path::Node* current_node = & (path->nodes[current_node_nr]); + const Path::Node* next_node = & (path->nodes[next_node_nr]); Vector new_pos = current_node->position + (next_node->position - current_node->position) * node_time; @@ -93,7 +102,6 @@ PathWalker::stop_moving() stop_at_node_nr = next_node_nr; } - void PathWalker::advance_node() { @@ -150,3 +158,5 @@ PathWalker::goback_node() next_node_nr = 0; walking_speed = 0; } + +/* EOF */