supertux
magicblock.hpp
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 HEADER_SUPERTUX_OBJECT_MAGICBLOCK_HPP
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 block"); }
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;
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 */
Simple two dimensional vector.
Definition: vector.hpp:24
virtual void update(float dt_sec) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: magicblock.cpp:119
Definition: magicblock.hpp:31
Definition: object_settings.hpp:35
Definition: rectf.hpp:29
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual bool collides(GameObject &other, const CollisionHit &hit) const override
when 2 objects collided, we will first call the pre_collision_check functions of both objects that ca...
Definition: magicblock.cpp:196
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: magicblock.cpp:186
Definition: color.hpp:25
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: magicblock.cpp:202
Definition: reader_mapping.hpp:31
Abstract base class for MovingObjects that are represented by a Sprite.
Definition: moving_sprite.hpp:29
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
This class collects data about a collision.
Definition: collision_hit.hpp:44