supertux
snail.hpp
1 // SuperTux - Badguy "Snail"
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_SNAIL_HPP
18 #define HEADER_SUPERTUX_BADGUY_SNAIL_HPP
19 
20 #include "badguy/walking_badguy.hpp"
21 
24 class Snail final :
25  public WalkingBadguy
26 {
27 public:
28  Snail(const ReaderMapping& reader);
29 
30  virtual void initialize() override;
31  virtual void collision_solid(const CollisionHit& hit) override;
32  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
33  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
34  virtual bool can_break() const override;
35 
36  virtual void active_update(float dt_sec) override;
37 
38  virtual bool is_freezable() const override;
39  virtual bool is_snipable() const override;
40 
41  static std::string class_name() { return "snail"; }
42  virtual std::string get_class_name() const override { return class_name(); }
43  static std::string display_name() { return _("Snail"); }
44  virtual std::string get_display_name() const override { return display_name(); }
45  virtual GameObjectClasses get_class_types() const override { return WalkingBadguy::get_class_types().add(typeid(Snail)); }
46 
47  virtual GameObjectTypes get_types() const override;
48  std::string get_default_sprite_name() const override;
49 
50  virtual bool is_portable() const override;
51  virtual void ungrab(MovingObject& , Direction dir_) override;
52  virtual void grab(MovingObject&, const Vector& pos, Direction dir_) override;
53 
54 protected:
55  virtual bool collision_squished(GameObject& object) override;
56 
57 private:
58  void be_normal();
59  void be_guard();
60  void be_flat();
61  void be_kicked(bool upwards);
62  void be_grabbed();
63  void wake_up();
64 
65 private:
66  enum State {
67  STATE_NORMAL,
68  STATE_GUARD_SHAKE,
69  STATE_GUARD,
70  STATE_GUARD_RETRACT,
71  STATE_FLAT,
72  STATE_WAKING,
73  STATE_KICKED_DELAY,
74  STATE_KICKED,
75  STATE_GRABBED,
76  };
77  enum Type {
78  NORMAL,
79  CORRUPTED
80  };
81 
82 private:
83  State state;
84  Timer kicked_delay_timer;
85  Timer flat_timer;
86  Timer m_guard_timer;
87  Timer m_guard_end_timer;
88  int squishcount;
89 
90 private:
91  Snail(const Snail&) = delete;
92  Snail& operator=(const Snail&) = delete;
93 };
94 
95 #endif
96 
97 /* EOF */
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:38
virtual GameObjectTypes get_types() const override
Get all types of the object, if available.
Definition: snail.cpp:66
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: walking_badguy.hpp:55
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: snail.cpp:156
Base class for Badguys that walk on the floor.
Definition: walking_badguy.hpp:25
virtual bool collision_squished(GameObject &object) override
Called when the player hit the badguy from above.
Definition: snail.cpp:339
virtual bool can_break() const override
True if this badguy can break bricks or open bonusblocks in his current form.
Definition: snail.cpp:150
virtual GameObjectClasses get_class_types() const override
List notable classes in inheritance hierarchy of class.
Definition: snail.hpp:45
This class is responsible for: Updating and drawing the object.
Definition: game_object.hpp:83
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: snail.cpp:314
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: snail.cpp:235
Badguy "Snail" - a snail-like creature that can be flipped and tossed around at an angle...
Definition: snail.hpp:24
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:35
virtual std::string get_display_name() const override
Returns the display name of the object, translated to the user&#39;s locale.
Definition: snail.hpp:44
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
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: snail.cpp:242
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: snail.cpp:287
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:32
virtual void grab(MovingObject &, const Vector &pos, Direction dir_) override
called each frame when the object has been grabbed.
Definition: snail.cpp:387
This module contains methods controlling the player.
Definition: player.hpp:47
virtual void initialize() override
called immediately before the first call to initialize
Definition: snail.cpp:59
This class collects data about a collision.
Definition: collision_hit.hpp:44