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 "squirrel/exposed_object.hpp"
22 #include "scripting/torch.hpp"
23 #include "sprite/sprite_ptr.hpp"
24 #include "supertux/moving_object.hpp"
25 
26 class ReaderMapping;
27 
28 class Torch final :
29  public MovingObject,
30  public ExposedObject<Torch, scripting::Torch>
31 {
32 public:
33  Torch(const ReaderMapping& reader);
34 
35  virtual void draw(DrawingContext& context) override;
36  virtual void update(float) override;
37 
38  virtual HitResponse collision(GameObject& other, const CollisionHit& ) override;
39 
40  virtual std::string get_class() const override { return "torch"; }
41  virtual std::string get_display_name() const override { return _("Torch"); }
42 
43  virtual ObjectSettings get_settings() override;
44  virtual void after_editor_set() override;
45 
48  bool get_burning() const;
49  void set_burning(bool burning_);
53 private:
54  SpritePtr m_torch;
55  SpritePtr m_flame;
56  SpritePtr m_flame_glow;
57  SpritePtr m_flame_light;
58  bool m_burning;
59  std::string sprite_name;
60 
61 private:
62  Torch(const Torch&) = delete;
63  Torch& operator=(const Torch&) = delete;
64 };
65 
66 #endif
67 
68 /* EOF */
void set_burning(bool burning_)
true: light torch, false: extinguish torch
Definition: torch.cpp:108
This class binds a certain GameObject class to a scripting class.
Definition: exposed_object.hpp:45
Definition: object_settings.hpp:35
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
bool get_burning() const
returns true if torch is lighted
Definition: torch.cpp:102
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:68
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:31
virtual void draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: torch.cpp:50
Definition: reader_mapping.hpp:31
This class provides functions for drawing things on screen.
Definition: drawing_context.hpp:42
Definition: torch.hpp:28
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:73