supertux
decal.hpp
1 // SuperTux - Decal
2 // Copyright (C) 2008 Christoph Sommer <christoph.sommer@2008.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_DECAL_HPP
18 #define HEADER_SUPERTUX_OBJECT_DECAL_HPP
19 
20 #include "object/moving_sprite.hpp"
21 #include "supertux/timer.hpp"
22 
23 class ReaderMapping;
24 
33 class Decal final : public MovingSprite
34 {
35  friend class FlipLevelTransformer;
36 
37 public:
38  static void register_class(ssq::VM& vm);
39 
40 public:
41  Decal(const ReaderMapping& reader);
42  ~Decal() override;
43 
44  virtual HitResponse collision(GameObject& , const CollisionHit& ) override { return FORCE_MOVE; }
45 
46  static std::string class_name() { return "decal"; }
47  virtual std::string get_class_name() const override { return class_name(); }
48  virtual std::string get_exposed_class_name() const override { return "Decal"; }
49  static std::string display_name() { return _("Decal"); }
50  virtual std::string get_display_name() const override { return display_name(); }
51  virtual GameObjectClasses get_class_types() const override { return MovingSprite::get_class_types().add(typeid(Decal)); }
52 
53  virtual ObjectSettings get_settings() override;
54 
55  virtual void draw(DrawingContext& context) override;
56  virtual void update(float dt_sec) override;
57 
58  virtual void on_flip(float height) override;
59 
66  void fade_sprite(const std::string& sprite, float time);
67 #ifdef DOXYGEN_SCRIPTING
68 
74  void change_sprite(const std::string& sprite);
75 #endif
76 
81  void fade_in(float time);
87  void fade_out(float time);
88 
89  void set_visible(bool v) { m_visible = v; }
90  bool is_visible() const { return m_visible; }
91 
92 private:
93  std::string m_default_action;
94  bool m_solid;
95  SpritePtr m_fade_sprite;
96  Timer m_fade_timer;
97  Timer m_sprite_timer;
98  bool m_visible;
99 
100 private:
101  Decal(const Decal&) = delete;
102  Decal& operator=(const Decal&) = delete;
103 };
104 
105 #endif
106 
107 /* EOF */
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: decal.cpp:107
virtual HitResponse collision(GameObject &, const CollisionHit &) override
this function is called when the object collided with any other object
Definition: decal.hpp:44
A decorative image, perhaps part of the terrain.
Definition: decal.hpp:33
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: decal.hpp:50
void fade_in(float time)
Fades in the decal in ""time"" seconds.
Definition: decal.cpp:72
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: decal.hpp:51
void fade_sprite(const std::string &sprite, float time)
Fades the decal sprite to a new one in ""time"" seconds.
Definition: decal.cpp:90
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 draw(DrawingContext &context) override
The GameObject should draw itself onto the provided DrawingContext if this function is called...
Definition: decal.cpp:63
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
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Vertically or horizontally flip a level.
Definition: flip_level_transformer.hpp:34
void fade_out(float time)
Fades out the decal in ""time"" seconds.
Definition: decal.cpp:81
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
This class collects data about a collision.
Definition: collision_hit.hpp:44
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: decal.cpp:100