supertux
lantern.hpp
1 // SuperTux - Lantern
2 // Copyright (C) 2006 Wolfgang Becker <uafr@gmx.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_LANTERN_HPP
18 #define HEADER_SUPERTUX_OBJECT_LANTERN_HPP
19 
20 #include "object/rock.hpp"
21 
23 class Lantern final : public Rock
24 {
25 public:
26  Lantern(const Vector& pos);
27  Lantern(const ReaderMapping& reader);
28 
29  virtual void draw(DrawingContext& context) override;
30 
31  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
32 
33  virtual void grab(MovingObject& object, const Vector& pos, Direction dir) override;
34  virtual void ungrab(MovingObject& object, Direction dir) override;
35 
36  static std::string class_name() { return "lantern"; }
37  virtual std::string get_class_name() const override { return class_name(); }
38  static std::string display_name() { return _("Lantern"); }
39  virtual std::string get_display_name() const override { return display_name(); }
40  virtual GameObjectClasses get_class_types() const override { return Rock::get_class_types().add(typeid(Lantern)); }
41 
42  virtual ObjectSettings get_settings() override;
43  virtual GameObjectTypes get_types() const override { return {}; }
44  virtual void after_editor_set() override;
45 
47  bool is_open() const;
48 
50  Color get_color() const { return lightcolor; }
51  void add_color(const Color& c);
52 
53 private:
54  Color lightcolor;
55  SpritePtr lightsprite;
56  void updateColor();
57 
58 private:
59  Lantern(const Lantern&) = delete;
60  Lantern& operator=(const Lantern&) = delete;
61 };
62 
63 #endif
64 
65 /* EOF */
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: lantern.hpp:40
bool is_open() const
returns true if lamp is currently open
Definition: lantern.cpp:146
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: lantern.hpp:39
Lantern.
Definition: lantern.hpp:23
Definition: object_settings.hpp:39
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: lantern.hpp:43
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: lantern.cpp:91
Color get_color() const
returns the lamp&#39;s color
Definition: lantern.hpp:50
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
virtual void grab(MovingObject &object, const Vector &pos, Direction dir) override
called each frame when the object has been grabbed.
Definition: lantern.cpp:123
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: lantern.cpp:98
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: rock.hpp:42
Definition: reader_mapping.hpp:32
Definition: rock.hpp:24
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