supertux
cloud_particle_system.hpp
1 // SuperTux
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.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_CLOUD_PARTICLE_SYSTEM_HPP
18 #define HEADER_SUPERTUX_OBJECT_CLOUD_PARTICLE_SYSTEM_HPP
19 
20 #include "object/particlesystem.hpp"
21 
22 #include "video/surface_ptr.hpp"
23 
24 class ReaderMapping;
25 
32 class CloudParticleSystem final : public ParticleSystem
33 {
34 public:
35  static void register_class(ssq::VM& vm);
36 
37 public:
39  CloudParticleSystem(const ReaderMapping& reader);
40  ~CloudParticleSystem() override;
41 
42  void init();
43  virtual void update(float dt_sec) override;
44 
45  virtual void draw(DrawingContext& context) override;
46 
47  static std::string class_name() { return "particles-clouds"; }
48  virtual std::string get_class_name() const override { return class_name(); }
49  virtual std::string get_exposed_class_name() const override { return "CloudParticleSystem"; }
50  static std::string display_name() { return _("Cloud Particles"); }
51  virtual std::string get_display_name() const override { return display_name(); }
52  virtual GameObjectClasses get_class_types() const override { return ParticleSystem::get_class_types().add(typeid(CloudParticleSystem)); }
53  virtual ObjectSettings get_settings() override;
54 
55  virtual const std::string get_icon_path() const override {
56  return "images/engine/editor/clouds.png";
57  }
58 
65  void fade_speed(float speed, float time);
73  void fade_amount(int amount, float time, float time_between);
80  void set_amount(int amount, float time);
81 
82  // Minimum and maximum multiplier for the amount of clouds
83  static int constexpr const max_amount = 500;
84  static int constexpr const min_amount = 0;
85 
86 private:
88  int add_clouds(int amount, float fade_time);
89 
91  int remove_clouds(int amount, float fade_time);
92 
93 private:
94  class CloudParticle : public Particle
95  {
96  public:
97  float speed;
98  float target_alpha;
99  float target_time_remaining;
100 
101  CloudParticle() :
102  speed(),
103  target_alpha(),
104  target_time_remaining()
105  {}
106  };
107 
108  SurfacePtr cloudimage;
109 
110  float m_current_speed;
111  float m_target_speed;
112  float m_speed_fade_time_remaining;
113 
114  int m_current_amount;
115  int m_current_real_amount;
116 
117 private:
118  CloudParticleSystem(const CloudParticleSystem&) = delete;
119  CloudParticleSystem& operator=(const CloudParticleSystem&) = delete;
120 };
121 
122 #endif
123 
124 /* EOF */
void fade_amount(int amount, float time, float time_between)
Smoothly changes the amount of particles to the given value in ""time"" seconds.
Definition: cloud_particle_system.cpp:213
void set_amount(int amount, float time)
Smoothly changes the amount of particles to the given value in ""time"" seconds.
Definition: cloud_particle_system.cpp:230
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: cloud_particle_system.cpp:236
void fade_speed(float speed, float time)
Smoothly changes the rain speed to the given value in ""time"" seconds.
Definition: cloud_particle_system.cpp:199
Definition: particlesystem.hpp:86
Definition: object_settings.hpp:39
This is the base class for particle systems.
Definition: particlesystem.hpp:49
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: cloud_particle_system.hpp:52
A ""CloudParticleSystem"" that was given a name can be controlled by scripts.
Definition: cloud_particle_system.hpp:32
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: cloud_particle_system.cpp:82
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: particlesystem.hpp:66
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 std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: cloud_particle_system.hpp:51
Definition: reader_mapping.hpp:32
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42