07936fbf6536e380feea6c9f2389714ade22fcc1
[supertux.git] / src / object / pneumatic_platform.hpp
1 //  $Id$
2 //
3 //  SuperTux - PneumaticPlatform
4 //  Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.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  02111-1307, USA.
19
20 #ifndef __PNEUMATIC_PLATFORM_H__
21 #define __PNEUMATIC_PLATFORM_H__
22
23 #include <memory>
24 #include <string>
25 #include <set>
26 #include "object/moving_sprite.hpp"
27 #include "object/path.hpp"
28 #include "object/path_walker.hpp"
29
30 /**
31  * Used to construct a pair of pneumatic platforms: If one is pushed down, the other one rises
32  */
33 class PneumaticPlatform : public MovingSprite
34 {
35 public:
36   PneumaticPlatform(const lisp::Lisp& reader);
37   PneumaticPlatform(PneumaticPlatform* master);
38   virtual ~PneumaticPlatform();
39
40   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
41   virtual void update(float elapsed_time);
42
43 protected:
44   PneumaticPlatform* master; /**< pointer to PneumaticPlatform that does movement calculation */
45   PneumaticPlatform* slave; /**< pointer to PneumaticPlatform that reacts to master platform's movement calculation */
46   float start_y; /**< vertical start position */
47   float offset_y; /**< vertical offset from the start position in px */
48   float speed_y; /**< vertical speed */
49   std::set<GameObject*> contacts; /**< objects that are currently pushing on the platform */
50
51 };
52
53 #endif