supertux
mole.hpp
1 // SuperTux - Mole Badguy
2 // Copyright (C) 2006 Christoph Sommer <christoph.sommer@2006.expires.deltadevelopment.de>
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_MOLE_HPP
18 #define HEADER_SUPERTUX_BADGUY_MOLE_HPP
19 
20 #include "badguy/badguy.hpp"
21 
22 class Mole final : public BadGuy
23 {
24 public:
25  Mole(const ReaderMapping& );
26 
27  virtual void kill_fall() override;
28  virtual HitResponse collision_badguy(BadGuy& , const CollisionHit& ) override;
29  virtual bool collision_squished(GameObject& object) override;
30 
31  virtual void activate() override;
32  virtual void active_update(float) override;
33 
34  virtual void ignite() override;
35 
36  static std::string class_name() { return "mole"; }
37  virtual std::string get_class_name() const override { return class_name(); }
38  static std::string display_name() { return _("Mole"); }
39  virtual std::string get_display_name() const override { return display_name(); }
40  virtual GameObjectClasses get_class_types() const override { return BadGuy::get_class_types().add(typeid(Mole)); }
41 
42  virtual bool is_snipable() const override { return true; }
43 
44  virtual void on_flip(float height) override;
45 
46 protected:
47  virtual std::vector<Direction> get_allowed_directions() const override;
48 
49 private:
50  enum MoleState {
51  PRE_THROWING,
52  THROWING,
53  POST_THROWING,
54  PEEKING,
55  DEAD,
56  BURNING
57  };
58 
59 private:
60  void set_state(MoleState new_state);
61  void throw_rock();
62 
63 private:
64  MoleState state;
65  Timer timer;
66  Timer throw_timer;
67  int cycle_num;
68 
69 private:
70  Mole(const Mole&) = delete;
71  Mole& operator=(const Mole&) = delete;
72 };
73 
74 #endif
75 
76 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual void active_update(float) override
called each frame when the badguy is activated.
Definition: mole.cpp:97
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: badguy.hpp:71
virtual void ignite() override
Kills the badguy by igniting it.
Definition: mole.cpp:176
virtual HitResponse collision_badguy(BadGuy &, const CollisionHit &) override
Called when the badguy collided with another badguy.
Definition: mole.cpp:66
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: mole.hpp:39
virtual void on_flip(float height) override
When level is flipped vertically.
Definition: mole.cpp:189
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: mole.cpp:72
virtual std::vector< Direction > get_allowed_directions() const override
Returns a vector of directions the badguy can be set to.
Definition: mole.cpp:183
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual void activate() override
called when the badguy has been activated.
Definition: mole.cpp:49
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: mole.hpp:40
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: mole.hpp:22
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: mole.hpp:42
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
virtual void kill_fall() override
Set the badguy to kill/falling state, which makes him falling of the screen (his sprite is turned ups...
Definition: mole.cpp:55
This class collects data about a collision.
Definition: collision_hit.hpp:44