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  virtual ~PneumaticPlatformChild();
31 
32  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
33  virtual void update(float dt_sec) override;
34  virtual bool is_saveable() const override { return false; }
35 
36  virtual void editor_delete() override;
37 
38 protected:
39  PneumaticPlatform& m_parent;
40  bool m_left;
41  std::set<GameObject*> m_contacts;
43 private:
45  PneumaticPlatformChild& operator=(const PneumaticPlatformChild&) = delete;
46 };
47 
50 class PneumaticPlatform final : public GameObject
51 {
52  friend class PneumaticPlatformChild;
53 
54 public:
55  PneumaticPlatform(const ReaderMapping& mapping);
56  virtual ~PneumaticPlatform();
57 
58  virtual void draw(DrawingContext& context) override;
59  virtual void update(float dt_sec) override;
60 
61  virtual std::string get_class() const override { return "pneumatic-platform"; }
62  virtual std::string get_display_name() const override { return _("Pneumatic platform"); }
63 
64  virtual ObjectSettings get_settings() override;
65  virtual void after_editor_set() override;
66  virtual void editor_delete() override;
67 
68 private:
69  Vector m_pos;
70  std::string m_sprite_name;
71  float m_start_y;
72  float m_speed_y;
73  float m_offset_y;
74  std::vector<PneumaticPlatformChild*> m_children;
75 
76 private:
77  PneumaticPlatform(const PneumaticPlatform&) = delete;
78  PneumaticPlatform& operator=(const PneumaticPlatform&) = delete;
79 };
80 
81 #endif
82 
83 /* EOF */
virtual bool is_saveable() const override
Indicates if the object will be saved.
Definition: pneumatic_platform.hpp:34
std::set< GameObject * > m_contacts
objects that are currently pushing on the platform
Definition: pneumatic_platform.hpp:41
Simple two dimensional vector.
Definition: vector.hpp:24
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:47
Definition: object_settings.hpp:35
Used to construct a pair of pneumatic platforms: If one is pushed down, the other one rises...
Definition: pneumatic_platform.hpp:50
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: pneumatic_platform.cpp:40
virtual void editor_delete() override
The editor requested the deletion of the object.
Definition: pneumatic_platform.cpp:66
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
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