supertux
goldbomb.hpp
1 // SuperTux BadGuy GoldBomb - a bomb that throws up coins when exploding
2 // Copyright (C) 2006 Matthias Braun <matze@braunis.de>
3 // Copyright (C) 2013 LMH <lmh.0013@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 
19 #ifndef HEADER_SUPERTUX_BADGUY_GOLDBOMB_HPP
20 #define HEADER_SUPERTUX_BADGUY_GOLDBOMB_HPP
21 
22 #include "badguy/mrbomb.hpp"
23 
24 class SoundSource;
25 
26 class GoldBomb final : public MrBomb
27 {
28 public:
29  GoldBomb(const ReaderMapping& reader);
30 
31  virtual void collision_solid(const CollisionHit& hit) override;
32 
33  virtual void active_update(float dt_sec) override;
34  static std::string class_name() { return "goldbomb"; }
35  virtual std::string get_class_name() const override { return class_name(); }
36  static std::string display_name() { return _("Gold Bomb"); }
37  virtual std::string get_display_name() const override { return display_name(); }
38  virtual GameObjectClasses get_class_types() const override { return WalkingBadguy::get_class_types().add(typeid(GoldBomb)); }
39  virtual bool is_snipable() const override { return true; }
40 
41  virtual void explode() override;
42 
43 private:
44  void flee(Direction dir);
45  void cornered();
46  void recover();
47  void normalize();
48 
49 private:
50  enum State : uint8_t {
51  GB_STATE_REALIZING = MB_STATE_COUNT,
52  GB_STATE_FLEEING,
53  GB_STATE_CORNERED,
54  GB_STATE_RECOVER
55  };
56 
57  Timer m_realize_timer;
58 
59 private:
60  GoldBomb(const GoldBomb&) = delete;
61  GoldBomb& operator=(const GoldBomb&) = delete;
62 };
63 
64 #endif
65 
66 /* EOF */
Definition: goldbomb.hpp:26
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: goldbomb.cpp:65
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: walking_badguy.hpp:55
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: goldbomb.hpp:37
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: goldbomb.cpp:51
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: goldbomb.hpp:38
Definition: mrbomb.hpp:25
A sound source represents the source of audio output.
Definition: sound_source.hpp:25
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: goldbomb.hpp:39
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
This class collects data about a collision.
Definition: collision_hit.hpp:44