rublight.hpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. // SuperTux
  2. //
  3. // This program is free software: you can redistribute it and/or modify
  4. // it under the terms of the GNU General Public License as published by
  5. // the Free Software Foundation, either version 3 of the License, or
  6. // (at your option) any later version.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. #ifndef HEADER_SUPERTUX_OBJECT_RUBLIGHT_HPP
  16. #define HEADER_SUPERTUX_OBJECT_RUBLIGHT_HPP
  17. #include "object/moving_sprite.hpp"
  18. #include "sprite/sprite_ptr.hpp"
  19. #include "video/color.hpp"
  20. /** A triboluminescent (or something similar) block */
  21. class RubLight final : public MovingSprite
  22. {
  23. public:
  24. RubLight(const ReaderMapping& mapping);
  25. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  26. virtual void update(float dt_sec) override;
  27. virtual void draw(DrawingContext& context) override;
  28. static std::string class_name() { return "rublight"; }
  29. virtual std::string get_class_name() const override { return class_name(); }
  30. static std::string display_name() { return _("Rublight"); }
  31. virtual std::string get_display_name() const override { return display_name(); }
  32. virtual ObjectSettings get_settings() override;
  33. virtual void on_flip(float height) override;
  34. private:
  35. enum State {
  36. STATE_DARK,
  37. STATE_FADING
  38. };
  39. State state;
  40. float stored_energy;
  41. SpritePtr light;
  42. Color color;
  43. float fading_speed;
  44. float strength_multiplier;
  45. private:
  46. void rub(float strength);
  47. float get_brightness() const;
  48. RubLight(const RubLight&) = delete;
  49. RubLight& operator=(const RubLight&) = delete;
  50. };
  51. #endif
  52. /* EOF */