Removed trailing whitespace from all *.?pp files
[supertux.git] / src / object / platform.hpp
1 //  SuperTux
2 //  Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 //
4 //  This program is free software: you can redistribute it and/or modify
5 //  it under the terms of the GNU General Public License as published by
6 //  the Free Software Foundation, either version 3 of the License, or
7 //  (at your option) any later version.
8 //
9 //  This program is distributed in the hope that it will be useful,
10 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
11 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 //  GNU General Public License for more details.
13 //
14 //  You should have received a copy of the GNU General Public License
15 //  along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 #ifndef HEADER_SUPERTUX_OBJECT_PLATFORM_HPP
18 #define HEADER_SUPERTUX_OBJECT_PLATFORM_HPP
19
20 #include "object/moving_sprite.hpp"
21 #include "object/path_walker.hpp"
22 #include "supertux/script_interface.hpp"
23
24 /**
25  * This class is the base class for platforms that tux can stand on
26  */
27 class Platform : public MovingSprite,
28                  public ScriptInterface
29 {
30 public:
31   Platform(const Reader& reader);
32   Platform(const Platform& platform);
33
34   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
35   virtual void update(float elapsed_time);
36
37   const Vector& get_speed() const
38   {
39     return speed;
40   }
41
42   /**
43    * @name Scriptable Methods
44    * @{
45    */
46
47   /** Move platform until at given node, then stop */
48   void goto_node(int node_no);
49
50   /** Start moving platform */
51   void start_moving();
52
53   /** Stop platform at next node */
54   void stop_moving();
55
56   /**
57    * @}
58    */
59
60   virtual void expose(HSQUIRRELVM vm, SQInteger table_idx);
61   virtual void unexpose(HSQUIRRELVM vm, SQInteger table_idx);
62
63   Path& get_path() {
64     return *path.get();
65   }
66
67 private:
68   std::unique_ptr<Path> path;
69   std::unique_ptr<PathWalker> walker;
70
71   Vector speed;
72
73   bool automatic; /**< true if Platform will automatically pick a destination based on collisions and current Player position */
74   bool player_contact; /**< true if a Player touched the Platform during the last round of collision detections */
75   bool last_player_contact; /**< true if a Player touched the Platform during the round before the last round of collision detections */
76
77 };
78
79 #endif
80
81 /* EOF */