supertux
ispy.hpp
1 // SuperTux - Ispy
2 // Copyright (C) 2007 Christoph Sommer <christoph.sommer@2007.expires.deltadevelopment.de>
3 // 2022 Jiri Palecek <narre@protonmail.com>
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_ISPY_HPP
19 #define HEADER_SUPERTUX_OBJECT_ISPY_HPP
20 
21 #include "object/sticky_object.hpp"
22 #include "supertux/direction.hpp"
23 
25 class Ispy final : public StickyObject
26 {
27 public:
28  Ispy(const ReaderMapping& mapping);
29 
30  virtual HitResponse collision(GameObject& other, const CollisionHit& hit) override;
31 
32  virtual void update(float dt_sec) override;
33  static std::string class_name() { return "ispy"; }
34  virtual std::string get_class_name() const override { return class_name(); }
35  static std::string display_name() { return _("Ispy"); }
36  virtual std::string get_display_name() const override { return display_name(); }
37  virtual GameObjectClasses get_class_types() const override { return StickyObject::get_class_types().add(typeid(Ispy)); }
38 
39  virtual ObjectSettings get_settings() override;
40  virtual void after_editor_set() override;
41 
42  virtual void on_flip(float height) override;
43 
44 private:
45  enum IspyState {
46  ISPYSTATE_IDLE,
47  ISPYSTATE_ALERT,
48  ISPYSTATE_HIDING,
49  ISPYSTATE_SHOWING
50  };
51 
52 private:
53  IspyState m_state;
55  std::string m_script;
56  Direction m_dir;
57 
58 private:
59  Ispy(const Ispy&) = delete;
60  Ispy& operator=(const Ispy&) = delete;
61 };
62 
63 #endif
64 
65 /* EOF */
virtual HitResponse collision(GameObject &other, const CollisionHit &hit) override
this function is called when the object collided with any other object
Definition: ispy.cpp:72
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: ispy.cpp:78
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: ispy.hpp:36
Definition: object_settings.hpp:39
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: ispy.hpp:37
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: ispy.cpp:134
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
An Ispy: When it spots Tux, a script will run.
Definition: ispy.hpp:25
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: sticky_object.hpp:34
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
This is a class for MovingSprites that can stick to the sides, top and bottom of MovingObjects, such as platforms, fallblock, tilemap, etc.
Definition: sticky_object.hpp:27
This class collects data about a collision.
Definition: collision_hit.hpp:44