supertux
ambient_light.hpp
1 // SuperTux
2 // Copyright (C) 2018 Ingo Ruhnke <grumbel@gmail.com>
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_AMBIENT_LIGHT_HPP
18 #define HEADER_SUPERTUX_OBJECT_AMBIENT_LIGHT_HPP
19 
20 #include "supertux/game_object.hpp"
21 
22 #include "video/color.hpp"
23 
24 class AmbientLight : public GameObject
25 {
26 public:
27  AmbientLight(const Color& color);
28  AmbientLight(const ReaderMapping& mapping);
29 
30  virtual void update(float dt_sec) override;
31  virtual void draw(DrawingContext& context) override;
32 
33  virtual bool is_singleton() const override { return true; }
34 
35  static std::string class_name() { return "ambient-light"; }
36  virtual std::string get_class_name() const override { return class_name(); }
37  static std::string display_name() { return _("Ambient Light"); }
38  virtual std::string get_display_name() const override { return display_name(); }
39  virtual const std::string get_icon_path() const override { return "images/engine/editor/ambient_light.png"; }
40  virtual GameObjectClasses get_class_types() const override { return GameObject::get_class_types().add(typeid(AmbientLight)); }
41 
42  virtual ObjectSettings get_settings() override;
43 
44  void set_ambient_light(const Color& ambient_light);
45  Color get_ambient_light() const;
46 
48  void fade_to_ambient_light(float red, float green, float blue, float seconds);
49 
50 private:
51  Color m_ambient_light;
52 
54  bool m_ambient_light_fading;
55 
57  Color m_source_ambient_light;
58 
60  Color m_target_ambient_light;
61 
63  float m_ambient_light_fade_duration;
64 
66  float m_ambient_light_fade_accum;
67 
68 private:
69  AmbientLight(const AmbientLight&) = delete;
70  AmbientLight& operator=(const AmbientLight&) = delete;
71 };
72 
73 #endif
74 
75 /* EOF */
void fade_to_ambient_light(float red, float green, float blue, float seconds)
Fades to the target ambient light.
Definition: ambient_light.cpp:102
virtual bool is_singleton() const override
If true only a single object of this type is allowed in a given GameObjectManager.
Definition: ambient_light.hpp:33
Definition: ambient_light.hpp:24
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: ambient_light.cpp:58
Definition: object_settings.hpp:39
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: ambient_light.hpp:38
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: ambient_light.hpp:40
virtual GameObjectClasses get_class_types() const
List notable classes in inheritance hierarchy of class.
Definition: game_object.cpp:113
Definition: color.hpp:26
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 void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: ambient_light.cpp:84
Definition: reader_mapping.hpp:32
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42