supertux
bicycle_platform.hpp
1 // SuperTux - BicyclePlatform
2 // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.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_BICYCLE_PLATFORM_HPP
18 #define HEADER_SUPERTUX_OBJECT_BICYCLE_PLATFORM_HPP
19 
20 #include "object/path_walker.hpp"
21 #include "object/moving_sprite.hpp"
22 
23 class BicyclePlatform;
24 
26 {
27  friend class BicyclePlatform;
28 
29 public:
30  BicyclePlatformChild(const ReaderMapping& reader, float angle_offset, BicyclePlatform& parent);
31 
32  virtual void update(float dt_sec) override;
33  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
34  virtual bool is_saveable() const override { return false; }
35 
36  virtual void editor_delete() override;
37 
38 private:
39  BicyclePlatform& m_parent;
40  float m_angle_offset;
41  float m_momentum;
42  std::set<GameObject*> m_contacts;
44 private:
46  BicyclePlatformChild& operator=(const BicyclePlatformChild&) = delete;
47 };
48 
52 class BicyclePlatform final : public GameObject
53 {
54  friend class BicyclePlatformChild;
55 
56 public:
57  BicyclePlatform(const ReaderMapping& reader);
58  virtual ~BicyclePlatform();
59 
60  virtual void draw(DrawingContext& context) override;
61  virtual void update(float dt_sec) override;
62 
63  virtual std::string get_class() const override { return "bicycle-platform"; }
64  virtual std::string get_display_name() const override { return _("Bicycle platform"); }
65 
66  virtual ObjectSettings get_settings() override;
67  virtual void editor_delete() override;
68  virtual void after_editor_set() override;
69 
70 private:
71  Vector m_center;
72  float m_radius;
74  float m_angle;
75  float m_angular_speed;
77  float m_momentum_change_rate;
79  std::vector<BicyclePlatformChild*> m_children;
80  std::unique_ptr<PathWalker> m_walker;
81  int m_platforms;
82 
83 private:
84  BicyclePlatform(const BicyclePlatform&) = delete;
85  BicyclePlatform& operator=(const BicyclePlatform&) = delete;
86 };
87 
88 #endif
89 
90 /* EOF */
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: bicycle_platform.cpp:50
Used to construct a pair of bicycle platforms: If one is pushed down, the other one rises...
Definition: bicycle_platform.hpp:52
virtual void editor_delete() override
The editor requested the deletion of the object.
Definition: bicycle_platform.cpp:76
Simple two dimensional vector.
Definition: vector.hpp:24
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: bicycle_platform.hpp:34
Definition: object_settings.hpp:35
Definition: bicycle_platform.hpp:25
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: moving_sprite.cpp:101
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: bicycle_platform.cpp:40
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44