4 // Copyright (C) 2005 Philipp <balinor@pnxs.de>
5 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
28 #include "math/vector.hpp"
29 #include "game_object.hpp"
30 #include "lisp/lisp.hpp"
34 * Helper class that stores an individual node of a Path
39 Vector position; /**< position (in pixels) of this node */
40 float time; /**< time (in seconds) to get to this node */
45 * Path an object can travel along. Made up of multiple nodes of type PathNode.
47 class Path : public GameObject
50 Path(const lisp::Lisp& reader);
53 virtual void update(float elapsed_time);
54 virtual void draw(DrawingContext& context);
56 const Vector& GetPosition();
57 const Vector& GetLastMovement();
59 // WARNING: returns NULL if not found !
60 static Path* GetByName(const std::string& name);
63 std::string name; /**< name this path can be referenced with, stored in PathRegistry */
64 bool circular; /**< true: start with the first node once the last one has been reached. false: path will stop at last node */
65 bool forward; /**< true: travel to nodes in the order they were defined. false: inverse order */
66 std::vector<PathNode> pathNodes; /**< list of nodes that make up this path */
68 Vector position; /**< current position */
69 Vector velocity; /**< current velocity */
70 Vector last_movement; /**< amount of pixels we moved in the last call to update */
72 int destinationNode; /**< current destination Node */
73 float timeToGo; /**< seconds until we arrive at the destination */
75 static std::map<std::string,Path*> registry;