supertux
ghoul.hpp
1 // SuperTux
2 //
3 // This program is free software: you can redistribute it and/or modify
4 // it under the terms of the GNU General Public License as published by
5 // the Free Software Foundation, either version 3 of the License, or
6 // (at your option) any later version.
7 //
8 // This program is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 // GNU General Public License for more details.
12 //
13 // You should have received a copy of the GNU General Public License
14 // along with this program. If not, see <http://www.gnu.org/licenses/>.
15 
16 #ifndef HEADER_SUPERTUX_BADGUY_GHOUL_HPP
17 #define HEADER_SUPERTUX_BADGUY_GHOUL_HPP
18 
19 #include "badguy/badguy.hpp"
20 #include "object/path_object.hpp"
21 
22 // FIXME: Ghoul inherits PathObject, but does not override get_settings() to add
23 // the missing options.
24 class Ghoul final : public BadGuy,
25  public PathObject
26 {
27 public:
28  Ghoul(const ReaderMapping& reader);
29  static std::string class_name() { return "ghoul"; }
30  static std::string display_name() { return _("Ghoul"); }
31  std::string get_class_name() const override { return class_name(); }
32  std::string get_display_name() const override { return display_name(); }
33  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(PathObject)).add(typeid(Ghoul)); }
34  bool is_freezable() const override;
35  bool is_flammable() const override;
36  virtual bool is_snipable() const override { return true; }
37 
38  void finish_construction() override;
39 
40  void activate() override;
41  void deactivate() override;
42  void active_update(float dt_sec) override;
43 
44  void goto_node(int node_idx);
45  void set_state(const std::string& state);
46  void start_moving();
47  void stop_moving();
48 
49  void move_to(const Vector& pos) override;
50 
51 protected:
52  bool collision_squished(GameObject& object) override;
53  std::vector<Direction> get_allowed_directions() const override;
54 
55 private:
56  enum MyState {
57  STATE_STOPPED, STATE_IDLE, STATE_TRACKING, STATE_PATHMOVING, STATE_PATHMOVING_TRACK
58  };
59 
60 private:
61  MyState m_mystate;
62  float m_flyspeed;
63  float m_track_range;
64 
65 private:
66  Ghoul(const Ghoul&) = delete;
67  Ghoul& operator=(const Ghoul&) = delete;
68 };
69 
70 #endif
71 
72 /* EOF */
bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: ghoul.cpp:48
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: ghoul.cpp:211
void deactivate() override
called when the badguy has been deactivated
Definition: ghoul.cpp:86
virtual bool is_snipable() const override
Can enemy be sniped by sliding or swimboosting Tux? Returns false if enemy is spiky or too large...
Definition: ghoul.hpp:36
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: ghoul.hpp:32
Definition: ghoul.hpp:24
bool is_flammable() const override
Returns whether to call ignite() when a badguy gets hit by a fire bullet.
Definition: ghoul.cpp:65
void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: ghoul.cpp:98
A base class for all objects that contain, or make use of a path.
Definition: path_object.hpp:36
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
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: ghoul.hpp:33
void finish_construction() override
Called after all objects have been added to the Sector and the Sector is fully constructed.
Definition: ghoul.cpp:71
void activate() override
called when the badguy has been activated.
Definition: ghoul.cpp:79