supertux
fish_swimming.hpp
1 // SuperTux
2 // Copyright (C) 2020 A. Semphris <semphris@protonmail.com>
3 // Copyright (C) 2022 Daniel Ward <weluvgoatz@gmail.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_BADGUY_FISH_SWIMMING_HPP
19 #define HEADER_SUPERTUX_BADGUY_FISH_SWIMMING_HPP
20 
21 #include "badguy/badguy.hpp"
22 
23 class FishSwimming : public BadGuy
24 {
25 public:
26  FishSwimming(const ReaderMapping& reader);
27  FishSwimming(const ReaderMapping& reader, const std::string& spritename);
28 
29  virtual void initialize() override;
30  virtual void collision_solid(const CollisionHit& hit) override;
31  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
32  virtual void update(float dt_sec) override;
33  virtual void active_update(float dt_sec) override;
34 
35  virtual void freeze() override;
36  virtual void unfreeze(bool melt = true) override;
37  virtual bool is_freezable() const override;
38  static std::string class_name() { return "fish-swimming"; }
39  virtual std::string get_class_name() const override { return class_name(); }
40  static std::string display_name() { return _("Swimming Fish"); }
41  virtual std::string get_display_name() const override { return display_name(); }
42  virtual std::string get_overlay_size() const override { return "2x1"; }
43  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(FishSwimming)); }
44  virtual ObjectSettings get_settings() override;
45 
46  virtual GameObjectTypes get_types() const override;
47  virtual std::string get_default_sprite_name() const override;
48 
49  void turn_around();
50  void maintain_velocity(float goal_x_velocity);
51 
52 protected:
53  enum Type {
54  SNOW,
55  FOREST,
56  CORRUPTED,
57  };
58 
59  enum FishYState {
60  DISRUPTED,
61  BALANCED
62  };
63 
64  FishYState m_state;
65  Timer m_beached_timer;
66  Timer m_float_timer;
67  float m_radius;
68 
69 private:
70  FishSwimming(const FishSwimming&) = delete;
71  FishSwimming& operator=(const FishSwimming&) = delete;
72 };
73 
74 #endif
75 
76 /* EOF */
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: fish_swimming.hpp:41
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
virtual void update(float dt_sec) override
Called each frame.
Definition: fish_swimming.cpp:136
Definition: object_settings.hpp:39
virtual void freeze() override
Called when hit by an ice bullet, and is_freezable() returns true.
Definition: fish_swimming.cpp:213
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: fish_swimming.hpp:43
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: fish_swimming.cpp:150
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: fish_swimming.cpp:122
virtual void initialize() override
called immediately before the first call to initialize
Definition: fish_swimming.cpp:89
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: fish_swimming.hpp:23
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: fish_swimming.cpp:53
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
virtual void unfreeze(bool melt=true) override
Called to unfreeze the badguy.
Definition: fish_swimming.cpp:221
Definition: reader_mapping.hpp:32
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: fish_swimming.cpp:97
This class collects data about a collision.
Definition: collision_hit.hpp:44