* The "time needed" statistic now works again. You might need to delete your savegame...
[supertux.git] / src / object / path.hpp
1 //  $Id$
2 // 
3 //  SuperTux
4 //  Copyright (C) 2005 Philipp <balinor@pnxs.de>
5 //
6 //  This program is free software; you can redistribute it and/or
7 //  modify it under the terms of the GNU General Public License
8 //  as published by the Free Software Foundation; either version 2
9 //  of the License, or (at your option) any later version.
10 //
11 //  This program is distributed in the hope that it will be useful,
12 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //  GNU General Public License for more details.
15 // 
16 //  You should have received a copy of the GNU General Public License
17 //  along with this program; if not, write to the Free Software
18 //  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19 //  02111-1307, USA.
20 #ifndef __PATH_HPP__
21 #define __PATH_HPP__
22
23 #include <string>
24 #include <list>
25 #include <map>
26
27 #include "math/vector.hpp"
28 #include "game_object.hpp"
29 #include "lisp/lisp.hpp"
30
31
32 class   Path;
33 typedef std::map<std::string,Path*>       PathRegistry;
34
35
36 typedef std::list<Vector>                 PathPoints;
37 typedef std::list<Vector>::const_iterator PathPointIter;
38
39
40 class Path : public GameObject
41 {
42 public:
43   Path(const lisp::Lisp& reader);
44   ~Path();
45
46   virtual void update(float elapsed_time);
47   virtual void draw(DrawingContext& context);
48
49   const Vector& GetPosition();
50   const Vector& GetStart();
51   const Vector& GetLastMovement();
52
53   // WARNING: returns NULL if not found !
54   static Path* GetByName(const std::string& name);
55
56 private:
57   std::string       name;
58   float             pixels_per_second;
59   PathPoints        points;     
60   PathPointIter     next_target;
61   Vector            pos;
62   Vector            velocity;
63   Vector            last_movement;
64
65   bool              circular;
66   bool              forward;
67
68   void calc_next_velocity();
69
70   static PathRegistry registry;
71 };
72
73 #endif