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 | |
24 | #ifndef HEADER_SUPERTUX_OBJECT_MAGICBLOCK_HPP |
25 | #define |
26 | |
27 | #include "object/moving_sprite.hpp" |
28 | |
29 | #include <memory> |
30 | |
31 | class MagicBlock final: public MovingSprite |
32 | { |
33 | public: |
34 | MagicBlock(const ReaderMapping& reader); |
35 | |
36 | virtual bool collides(GameObject& other, const CollisionHit& hit) const override; |
37 | virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override; |
38 | virtual void update(float dt_sec) override; |
39 | virtual void draw(DrawingContext& context) override; |
40 | virtual std::string get_class() const override { return "magicblock" ; } |
41 | virtual std::string get_display_name() const override { return _("Magic Tile" ); } |
42 | |
43 | virtual ObjectSettings get_settings() override; |
44 | virtual void after_editor_set() override; |
45 | |
46 | private: |
47 | bool m_is_solid; |
48 | float m_trigger_red; |
49 | float m_trigger_green; |
50 | float m_trigger_blue; |
51 | float m_solid_time; |
52 | float m_switch_delay; /**< seconds until switching solidity */ |
53 | Rectf m_solid_box; |
54 | Color m_color; |
55 | std::shared_ptr<Color> m_light; |
56 | Vector m_center; |
57 | bool m_black; |
58 | |
59 | private: |
60 | MagicBlock(const MagicBlock&) = delete; |
61 | MagicBlock& operator=(const MagicBlock&) = delete; |
62 | }; |
63 | |
64 | #endif |
65 | |
66 | /* EOF */ |
67 | |