supertux
fish_chasing.hpp
1 // SuperTux
2 // Copyright (C) 2022 Daniel Ward <weluvgoatz@gmail.com>
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_BADGUY_FISH_CHASING_HPP
18 #define HEADER_SUPERTUX_BADGUY_FISH_CHASING_HPP
19 
20 #include "badguy/fish_swimming.hpp"
21 
22 class FishChasing final : public FishSwimming
23 {
24 public:
25  FishChasing(const ReaderMapping& reader);
26 
27  virtual void active_update(float dt_sec) override;
28 
29  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
30 
31  static std::string class_name() { return "fish-chasing"; }
32  virtual std::string get_class_name() const override { return class_name(); }
33  static std::string display_name() { return _("Chasing Fish"); }
34  virtual std::string get_display_name() const override { return display_name(); }
35  virtual std::string get_overlay_size() const override { return "2x2"; }
36  virtual GameObjectClasses get_class_types() const override { return FishSwimming::get_class_types().add(typeid(FishChasing)); }
37  virtual ObjectSettings get_settings() override;
38 
39  std::string get_default_sprite_name() const override;
40 
41 private:
42  enum ChaseState {
43  NORMAL,
44  FOUND,
45  CHASING,
46  LOST
47  };
48 
49  ChaseState m_chase_state;
50  Timer m_realization_timer;
51  Timer m_acceleration_timer;
52  bool m_is_accelerating;
53  float m_last_chase_velocity;
54  float m_track_distance;
55  float m_lost_distance;
56  float m_chase_speed;
57 
58 private:
59  FishChasing(const FishChasing&) = delete;
60  FishChasing& operator=(const FishChasing&) = delete;
61 };
62 
63 #endif
64 
65 /* 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_chasing.hpp:34
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: fish_chasing.cpp:63
Definition: fish_chasing.hpp:22
Definition: object_settings.hpp:39
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: fish_chasing.hpp:36
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: fish_swimming.hpp:43
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: fish_chasing.cpp:184
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
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
This class collects data about a collision.
Definition: collision_hit.hpp:44