decal.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. // SuperTux - Decal
  2. // Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.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. #ifndef HEADER_SUPERTUX_OBJECT_DECAL_HPP
  17. #define HEADER_SUPERTUX_OBJECT_DECAL_HPP
  18. #include "object/moving_sprite.hpp"
  19. #include "scripting/decal.hpp"
  20. #include "squirrel/exposed_object.hpp"
  21. #include "supertux/timer.hpp"
  22. class ReaderMapping;
  23. /** A decorative image, perhaps part of the terrain */
  24. class Decal final : public MovingSprite,
  25. public ExposedObject<Decal, scripting::Decal>
  26. {
  27. friend class FlipLevelTransformer;
  28. public:
  29. Decal(const ReaderMapping& reader);
  30. ~Decal() override;
  31. virtual HitResponse collision(GameObject& , const CollisionHit& ) override { return FORCE_MOVE; }
  32. static std::string class_name() { return "decal"; }
  33. virtual std::string get_class_name() const override { return class_name(); }
  34. static std::string display_name() { return _("Decal"); }
  35. virtual std::string get_display_name() const override { return display_name(); }
  36. virtual ObjectSettings get_settings() override;
  37. virtual void draw(DrawingContext& context) override;
  38. virtual void update(float dt_sec) override;
  39. virtual void on_flip(float height) override;
  40. void fade_in(float fade_time);
  41. void fade_out(float fade_time);
  42. void fade_sprite(const std::string& new_sprite, float fade_time);
  43. void set_visible(bool v) { m_visible = v; }
  44. bool is_visible() const { return m_visible; }
  45. private:
  46. std::string m_default_action;
  47. bool m_solid;
  48. SpritePtr m_fade_sprite;
  49. Timer m_fade_timer;
  50. Timer m_sprite_timer;
  51. bool m_visible;
  52. private:
  53. Decal(const Decal&) = delete;
  54. Decal& operator=(const Decal&) = delete;
  55. };
  56. #endif
  57. /* EOF */