supertux
torch.hpp
1 // SuperTux
2 // Copyright (C) 2014 Ingo Ruhnke <grumbel@gmail.com>
3 // Copyright (C) 2017 M. Teufel <mteufel@supertux.org>
4 //
5 // This program is free software: you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation, either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 
18 #ifndef HEADER_SUPERTUX_OBJECT_TORCH_HPP
19 #define HEADER_SUPERTUX_OBJECT_TORCH_HPP
20 
21 #include "object/moving_sprite.hpp"
22 
23 class ReaderMapping;
24 
31 class Torch final : public MovingSprite
32 {
33 public:
34  static void register_class(ssq::VM& vm);
35 
36 public:
37  Torch(const ReaderMapping& reader);
38 
39  virtual void draw(DrawingContext& context) override;
40  virtual void update(float) override;
41 
42  virtual HitResponse collision(GameObject& other, const CollisionHit& ) override;
43 
44  static std::string class_name() { return "torch"; }
45  virtual std::string get_class_name() const override { return class_name(); }
46  virtual std::string get_exposed_class_name() const override { return "Torch"; }
47  static std::string display_name() { return _("Torch"); }
48  virtual std::string get_display_name() const override { return display_name(); }
49  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(Torch)); }
50 
51  virtual ObjectSettings get_settings() override;
52  virtual void after_editor_set() override;
53 
54  virtual int get_layer() const override { return m_layer; }
55 
56  virtual void on_flip(float height) override;
57 
63  bool get_burning() const;
70  void set_burning(bool burning);
71 
72 private:
73  Color m_light_color;
74  SpritePtr m_flame;
75  SpritePtr m_flame_glow;
76  SpritePtr m_flame_light;
77 
82  bool m_burning;
83 
84 private:
85  Torch(const Torch&) = delete;
86  Torch& operator=(const Torch&) = delete;
87 };
88 
89 #endif
90 
91 /* EOF */
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: torch.hpp:49
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: torch.hpp:48
int m_layer
Sprite&#39;s z-position.
Definition: moving_sprite.hpp:153
Definition: object_settings.hpp:39
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: torch.cpp:128
bool get_burning() const
Definition: torch.cpp:116
void set_burning(bool burning)
Definition: torch.cpp:122
virtual void update(float) override
This function is called once per frame and allows the object to update it&#39;s state.
Definition: torch.cpp:76
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: torch.cpp:56
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
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
A ""Torch"" that was given a name can be controlled by scripts.
Definition: torch.hpp:31
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual HitResponse collision(GameObject &other, const CollisionHit &) override
this function is called when the object collided with any other object
Definition: torch.cpp:81