ambient_light.hpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. #ifndef HEADER_SUPERTUX_OBJECT_AMBIENT_LIGHT_HPP
  17. #define HEADER_SUPERTUX_OBJECT_AMBIENT_LIGHT_HPP
  18. #include "supertux/game_object.hpp"
  19. #include "video/color.hpp"
  20. class AmbientLight : public GameObject
  21. {
  22. public:
  23. AmbientLight(const Color& color);
  24. AmbientLight(const ReaderMapping& mapping);
  25. virtual void update(float dt_sec) override;
  26. virtual void draw(DrawingContext& context) override;
  27. virtual bool is_singleton() const override { return true; }
  28. static std::string class_name() { return "ambient-light"; }
  29. virtual std::string get_class_name() const override { return class_name(); }
  30. static std::string display_name() { return _("Ambient Light"); }
  31. virtual std::string get_display_name() const override { return display_name(); }
  32. virtual const std::string get_icon_path() const override { return "images/engine/editor/ambient_light.png"; }
  33. virtual ObjectSettings get_settings() override;
  34. void set_ambient_light(const Color& ambient_light);
  35. Color get_ambient_light() const;
  36. /** Fades to the target ambient light */
  37. void fade_to_ambient_light(float red, float green, float blue, float seconds);
  38. private:
  39. Color m_ambient_light;
  40. /** Specifies whether we're fading the ambient light*/
  41. bool m_ambient_light_fading;
  42. /** Source color for fading */
  43. Color m_source_ambient_light;
  44. /** Target color for fading */
  45. Color m_target_ambient_light;
  46. /** Ambient light fade duration */
  47. float m_ambient_light_fade_duration;
  48. /** Accumulated time for fading */
  49. float m_ambient_light_fade_accum;
  50. private:
  51. AmbientLight(const AmbientLight&) = delete;
  52. AmbientLight& operator=(const AmbientLight&) = delete;
  53. };
  54. #endif
  55. /* EOF */