supertux
pneumatic_platform.hpp
1 // SuperTux - PneumaticPlatform
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_PNEUMATIC_PLATFORM_HPP
18 #define HEADER_SUPERTUX_OBJECT_PNEUMATIC_PLATFORM_HPP
19 
20 #include "object/moving_sprite.hpp"
21 
22 class PneumaticPlatform;
23 
25 {
26  friend class PneumaticPlatform;
27 
28 public:
29  PneumaticPlatformChild(const ReaderMapping& reader, bool left, PneumaticPlatform& parent);
30  ~PneumaticPlatformChild() override;
31  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(PneumaticPlatformChild)); }
32 
33  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
34  virtual void update(float dt_sec) 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 protected:
41  PneumaticPlatform& m_parent;
42  bool m_left;
43  std::set<GameObject*> m_contacts;
45 private:
47  PneumaticPlatformChild& operator=(const PneumaticPlatformChild&) = delete;
48 };
49 
52 class PneumaticPlatform final : public GameObject
53 {
54  friend class PneumaticPlatformChild;
55 
56 public:
57  PneumaticPlatform(const ReaderMapping& mapping);
58  ~PneumaticPlatform() override;
59 
60  virtual void draw(DrawingContext& context) override;
61  virtual void update(float dt_sec) override;
62  virtual void on_flip(float height) override;
63 
64  static std::string class_name() { return "pneumatic-platform"; }
65  virtual std::string get_class_name() const override { return class_name(); }
66  static std::string display_name() { return _("Pneumatic Platform"); }
67  virtual std::string get_display_name() const override { return display_name(); }
68  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(PneumaticPlatform)); }
69 
70  virtual ObjectSettings get_settings() override;
71  virtual void after_editor_set() override;
72  virtual void editor_delete() override;
73 
74 private:
75  Vector m_pos;
76  std::string m_sprite_name;
77  float m_start_y;
78  float m_speed_y;
79  float m_offset_y;
80  std::vector<PneumaticPlatformChild*> m_children;
81 
82 private:
83  PneumaticPlatform(const PneumaticPlatform&) = delete;
84  PneumaticPlatform& operator=(const PneumaticPlatform&) = delete;
85 };
86 
87 #endif
88 
89 /* EOF */
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: pneumatic_platform.hpp:35
std::set< GameObject * > m_contacts
objects that are currently pushing on the platform
Definition: pneumatic_platform.hpp:43
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: pneumatic_platform.cpp:50
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: pneumatic_platform.hpp:31
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: pneumatic_platform.hpp:67
Definition: object_settings.hpp:39
Used to construct a pair of pneumatic platforms: If one is pushed down, the other one rises...
Definition: pneumatic_platform.hpp:52
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: pneumatic_platform.cpp:76
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: pneumatic_platform.hpp:68
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
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: pneumatic_platform.cpp:41
virtual void editor_delete() override
The editor requested the deletion of the object.
Definition: pneumatic_platform.cpp:69
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
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
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
Definition: pneumatic_platform.hpp:24
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