supertux
candle.hpp
1 // SuperTux
2 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 #ifndef HEADER_SUPERTUX_OBJECT_CANDLE_HPP
18 #define HEADER_SUPERTUX_OBJECT_CANDLE_HPP
19 
20 #include "object/moving_sprite.hpp"
21 
30 class Candle final : public MovingSprite
31 {
32 public:
33  static void register_class(ssq::VM& vm);
34 
35 public:
36  Candle(const ReaderMapping& mapping);
37  virtual void draw(DrawingContext& context) override;
38 
39  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
40  static std::string class_name() { return "candle"; }
41  virtual std::string get_class_name() const override { return class_name(); }
42  virtual std::string get_exposed_class_name() const override { return "Candle"; }
43  static std::string display_name() { return _("Candle"); }
44  virtual std::string get_display_name() const override { return display_name(); }
45  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(Candle)); }
46 
47  virtual ObjectSettings get_settings() override;
48  virtual void after_editor_set() override;
49 
50  virtual void on_flip(float height) override;
51 
56  void puff_smoke();
61  bool get_burning() const;
67  void set_burning(bool burning);
68 
69 private:
70  bool burning;
71  bool flicker;
72  Color lightcolor;
73  SpritePtr candle_light_1;
74  SpritePtr candle_light_2;
76 private:
77  Candle(const Candle&) = delete;
78  Candle& operator=(const Candle&) = delete;
79 };
80 
81 #endif
82 
83 /* EOF */
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: candle.cpp:86
void puff_smoke()
Spawns a puff of smoke.
Definition: candle.cpp:112
Definition: object_settings.hpp:39
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: candle.hpp:45
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: moving_sprite.hpp:60
A burning candle: Simple, scriptable level decoration.
Definition: candle.hpp:30
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
bool get_burning() const
Returns ""true"" if the candle is lit up.
Definition: candle.cpp:125
void set_burning(bool burning)
Sets the burning state of the candle.
Definition: candle.cpp:131
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: candle.cpp:106
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 std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: candle.hpp:44
Definition: reader_mapping.hpp:32
Abstract base class for ""MovingObject""s, that are represented by a sprite.
Definition: moving_sprite.hpp:33
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: candle.cpp:145
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