2dcd7790ad24d18f5983fb51b66c610cf7142107
[supertux.git] / src / object / bicycle_platform.hpp
1 //  $Id$
2 //
3 //  SuperTux - BicyclePlatform
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 __BICYCLE_PLATFORM_H__
21 #define __BICYCLE_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 bicycle platforms: If one is pushed down, the other one rises
32  */
33 class BicyclePlatform : public MovingSprite
34 {
35 public:
36   BicyclePlatform(const lisp::Lisp& reader);
37   BicyclePlatform(BicyclePlatform* master);
38   virtual ~BicyclePlatform();
39
40   virtual HitResponse collision(GameObject& other, const CollisionHit& hit);
41   virtual void update(float elapsed_time);
42
43 protected:
44   BicyclePlatform* master; /**< pointer to BicyclePlatform that does movement calculation */
45   BicyclePlatform* slave; /**< pointer to BicyclePlatform that reacts to master platform's movement calculation */
46   Vector center; /**< pivot point */
47   float radius; /**< radius of circle */
48   float angle; /**< current angle */
49   float angular_speed; /**< angular speed in rad per second */
50   std::set<GameObject*> contacts; /**< objects that are currently pushing on the platform */
51   float momentum; /** angular momentum in rad per second per second*/
52
53 };
54
55 #endif