-// $Id: path.hpp 3114 2006-03-23 23:47:04Z sommer $
-//
-// SuperTux Path
-// Copyright (C) 2005 Philipp <balinor@pnxs.de>
-// Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
+// $Id$
+//
+// SuperTux
// Copyright (C) 2006 Matthias Braun <matze@braunis.de>
//
// This program is free software; you can redistribute it and/or
// 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.
+
#include <config.h>
#include <math.h>
+#include <assert.h>
#include "path_walker.hpp"
PathWalker::PathWalker(const Path* path)
{
last_pos = path->nodes[0].position;
node_mult = 1 / path->nodes[0].time;
+ next_node_nr = path->nodes.size() > 1 ? 1 : 0;
}
PathWalker::~PathWalker()
const Path::Node* current_node = & (path->nodes[current_node_nr]);
while(node_time + elapsed_time * node_mult >= 1) {
- elapsed_time -= (1 - node_time) * node_mult;
+ elapsed_time -= (1 - node_time) / node_mult;
if(walking_speed > 0) {
advance_node();
switch(path->mode) {
case Path::PING_PONG:
walking_speed = -walking_speed;
+ next_node_nr = path->nodes.size() > 1 ? 1 : 0;
return;
default:
break;