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  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(BicyclePlatformChild)); }
32 
33  virtual void update(float dt_sec) override;
34  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
35  virtual bool is_saveable() const override { return false; }
36  virtual void on_flip(float height) override;
37 
38  virtual void editor_delete() override;
39 
40 private:
41  BicyclePlatform& m_parent;
42  float m_angle_offset;
43  float m_momentum;
44  std::set<GameObject*> m_contacts;
46 private:
48  BicyclePlatformChild& operator=(const BicyclePlatformChild&) = delete;
49 };
50 
54 class BicyclePlatform final : public GameObject
55 {
56  friend class BicyclePlatformChild;
57 
58 public:
59  BicyclePlatform(const ReaderMapping& reader);
60  ~BicyclePlatform() override;
61 
62  virtual void draw(DrawingContext& context) override;
63  virtual void update(float dt_sec) override;
64  virtual void on_flip(float height) override;
65 
66  static std::string class_name() { return "bicycle-platform"; }
67  virtual std::string get_class_name() const override { return class_name(); }
68  static std::string display_name() { return _("Bicycle Platform"); }
69  virtual std::string get_display_name() const override { return display_name(); }
70  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(BicyclePlatform)); }
71 
72  virtual ObjectSettings get_settings() override;
73  virtual void editor_delete() override;
74  virtual void after_editor_set() override;
75 
76 private:
77  Vector m_center;
78  float m_radius;
80  float m_angle;
81  float m_angular_speed;
83  float m_momentum_change_rate;
85  std::vector<BicyclePlatformChild*> m_children;
86  std::unique_ptr<PathWalker> m_walker;
87  int m_platforms;
88 
89 private:
90  BicyclePlatform(const BicyclePlatform&) = delete;
91  BicyclePlatform& operator=(const BicyclePlatform&) = delete;
92 };
93 
94 #endif
95 
96 /* 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:53
Used to construct a pair of bicycle platforms: If one is pushed down, the other one rises...
Definition: bicycle_platform.hpp:54
virtual void editor_delete() override
The editor requested the deletion of the object.
Definition: bicycle_platform.cpp:79
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: bicycle_platform.hpp:35
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: bicycle_platform.cpp:86
Definition: object_settings.hpp:39
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: bicycle_platform.hpp:31
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
Definition: bicycle_platform.hpp:25
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: moving_sprite.cpp:99
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:41
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: bicycle_platform.hpp:69
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: bicycle_platform.hpp:70
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
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