supertux
igel.hpp
1 // SuperTux - Badguy "Igel"
2 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
3 // 2023 MatusGuy
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_BADGUY_IGEL_HPP
19 #define HEADER_SUPERTUX_BADGUY_IGEL_HPP
20 
21 #include "badguy/walking_badguy.hpp"
22 
23 #include "supertux/timer.hpp"
24 
25 class Igel final : public WalkingBadguy
26 {
27 public:
28  Igel(const ReaderMapping& reader);
29 
30  virtual void active_update(float dt_sec) override;
31  virtual void collision_solid(const CollisionHit &hit) override;
32  virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override;
33  virtual bool can_break() const override;
34  virtual void run_dead_script() override;
35 
36  virtual std::string get_overlay_size() const override { return "2x1"; }
37  static std::string class_name() { return "igel"; }
38  virtual std::string get_class_name() const override { return class_name(); }
39  static std::string display_name() { return _("Igel"); }
40  virtual std::string get_display_name() const override { return display_name(); }
41  virtual GameObjectClasses get_class_types() const override { return WalkingBadguy::get_class_types().add(typeid(Igel)); }
42 
43  virtual bool is_freezable() const override { return true; }
44  virtual void unfreeze(bool melt = true) override;
45 
46  virtual GameObjectTypes get_types() const override;
47  virtual std::string get_default_sprite_name() const override;
48 
49 private:
50  enum Type { NORMAL, CORRUPTED };
51  enum State { STATE_NORMAL, STATE_CHARGING, STATE_ROLLING };
52 
53  bool should_roll() const;
54  void charge();
55  void roll();
56  void stop_rolling(bool bonk = false);
57  float get_normal_walk_speed() const;
58 
59 private:
60  State m_state;
61  Timer m_roll_timer;
62  Timer m_roll_cooldown;
63  Timer m_ease_timer;
64  bool m_bonked;
65 
66 private:
67  Igel(const Igel&) = delete;
68  Igel& operator=(const Igel&) = delete;
69 };
70 
71 #endif
72 
73 /* EOF */
virtual bool can_break() const override
True if this badguy can break bricks or open bonusblocks in his current form.
Definition: igel.cpp:151
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: igel.hpp:40
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: igel.cpp:139
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: walking_badguy.hpp:55
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: igel.cpp:125
Base class for Badguys that walk on the floor.
Definition: walking_badguy.hpp:25
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: igel.cpp:61
virtual void run_dead_script() override
Call this, if you use custom kill_fall() or kill_squashed(GameObject& object)
Definition: igel.cpp:157
virtual void unfreeze(bool melt=true) override
Called to unfreeze the badguy.
Definition: igel.cpp:171
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
Definition: reader_mapping.hpp:32
Definition: igel.hpp:25
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: igel.cpp:191
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: igel.hpp:41
This class collects data about a collision.
Definition: collision_hit.hpp:44