magicblock.hpp 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // SuperTux - MagicBlock
  2. //
  3. // Magic Blocks are tile-like game objects that are sensitive to
  4. // lighting conditions. They are rendered in a color and
  5. // will only be solid as long as light of the same color shines
  6. // on the block. The black block becomes solid, if any kind of
  7. // light is above MIN_INTENSITY.
  8. //
  9. // Copyright (C) 2006 Wolfgang Becker <uafr@gmx.de>
  10. //
  11. // This program is free software: you can redistribute it and/or modify
  12. // it under the terms of the GNU General Public License as published by
  13. // the Free Software Foundation, either version 3 of the License, or
  14. // (at your option) any later version.
  15. //
  16. // This program is distributed in the hope that it will be useful,
  17. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. // GNU General Public License for more details.
  20. //
  21. // You should have received a copy of the GNU General Public License
  22. // along with this program. If not, see <http://www.gnu.org/licenses/>.
  23. #ifndef HEADER_SUPERTUX_OBJECT_MAGICBLOCK_HPP
  24. #define HEADER_SUPERTUX_OBJECT_MAGICBLOCK_HPP
  25. #include "object/moving_sprite.hpp"
  26. #include <memory>
  27. class MagicBlock final: public MovingSprite
  28. {
  29. public:
  30. MagicBlock(const ReaderMapping& reader);
  31. virtual bool collides(GameObject& other, const CollisionHit& hit) const override;
  32. virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
  33. virtual void update(float dt_sec) override;
  34. virtual void draw(DrawingContext& context) override;
  35. static std::string class_name() { return "magicblock"; }
  36. virtual std::string get_class_name() const override { return class_name(); }
  37. static std::string display_name() { return _("Magic Tile"); }
  38. virtual std::string get_display_name() const override { return display_name(); }
  39. virtual ObjectSettings get_settings() override;
  40. virtual void after_editor_set() override;
  41. virtual void on_flip(float height) override;
  42. private:
  43. bool m_is_solid;
  44. float m_trigger_red;
  45. float m_trigger_green;
  46. float m_trigger_blue;
  47. float m_solid_time;
  48. float m_switch_delay; /**< seconds until switching solidity */
  49. Rectf m_solid_box;
  50. Color m_color;
  51. std::shared_ptr<Color> m_light;
  52. Vector m_center;
  53. bool m_black;
  54. private:
  55. MagicBlock(const MagicBlock&) = delete;
  56. MagicBlock& operator=(const MagicBlock&) = delete;
  57. };
  58. #endif
  59. /* EOF */