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  static std::string class_name() { return "magicblock"; }
41  virtual std::string get_class_name() const override { return class_name(); }
42  static std::string display_name() { return _("Magic Tile"); }
43  virtual std::string get_display_name() const override { return display_name(); }
44  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(MagicBlock)); }
45 
46  virtual ObjectSettings get_settings() override;
47  virtual void after_editor_set() override;
48 
49  virtual void on_flip(float height) override;
50 
51 private:
52  bool m_is_solid;
53  float m_trigger_red;
54  float m_trigger_green;
55  float m_trigger_blue;
56  float m_solid_time;
57  float m_switch_delay;
58  Rectf m_solid_box;
59  Color m_color;
60  std::shared_ptr<Color> m_light;
61  Vector m_center;
62  bool m_black;
63 
64 private:
65  MagicBlock(const MagicBlock&) = delete;
66  MagicBlock& operator=(const MagicBlock&) = delete;
67 };
68 
69 #endif
70 
71 /* EOF */
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: magicblock.hpp:43
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:122
Definition: magicblock.hpp:31
Definition: object_settings.hpp:39
Definition: rectf.hpp:31
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: magicblock.cpp:211
virtual bool collides(GameObject &other, const CollisionHit &hit) const override
when 2 objects collided, we will first call the collision functions of both objects that can decide o...
Definition: magicblock.cpp:199
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: magicblock.cpp:189
Definition: color.hpp:26
A helper structure to list all the type_indexes of the classes in the type hierarchy of a given class...
Definition: game_object.hpp:57
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: magicblock.cpp:205
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: magicblock.hpp:44
This class collects data about a collision.
Definition: collision_hit.hpp:44