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 #include "object/portable.hpp"
22 
25 class Snail final :
26  public WalkingBadguy,
27  public Portable
28 {
29 public:
30  Snail(const ReaderMapping& reader);
31 
32  virtual void initialize() override;
33  virtual void collision_solid(const CollisionHit& hit) override;
34  virtual HitResponse collision_badguy(BadGuy& badguy, const CollisionHit& hit) override;
35  virtual HitResponse collision_player(Player& player, const CollisionHit& hit) override;
36  virtual bool can_break() const override;
37 
38  virtual void active_update(float dt_sec) override;
39 
40  virtual bool is_freezable() const override;
41  virtual std::string get_class() const override { return "snail"; }
42  virtual std::string get_display_name() const override { return _("Snail"); }
43 
44  virtual bool is_portable() const override;
45  virtual void ungrab(MovingObject& , Direction dir_) override;
46  virtual void grab(MovingObject&, const Vector& pos, Direction dir_) override;
47 
48 protected:
49  virtual bool collision_squished(GameObject& object) override;
50 
51  void be_normal();
52  void be_flat();
53  void be_kicked();
54  void be_grabbed();
55 
56 private:
57  enum State {
58  STATE_NORMAL,
59  STATE_FLAT,
60  STATE_KICKED_DELAY,
61  STATE_KICKED,
62  STATE_GRABBED
63  };
64 
65 private:
66  State state;
67  Timer kicked_delay_timer;
68  int squishcount;
69 
70 private:
71  Snail(const Snail&) = delete;
72  Snail& operator=(const Snail&) = delete;
73 };
74 
75 #endif
76 
77 /* EOF */
void be_normal()
switch to state STATE_NORMAL
Definition: snail.cpp:52
Base class for moving sprites that can hurt the Player.
Definition: badguy.hpp:31
void be_kicked()
switch to state STATE_KICKED_DELAY
Definition: snail.cpp:77
Simple two dimensional vector.
Definition: vector.hpp:24
void be_flat()
switch to state STATE_FLAT
Definition: snail.cpp:61
An object that inherits from this object is considered "portable" and can be carried around by the pl...
Definition: portable.hpp:29
virtual void active_update(float dt_sec) override
called each frame when the badguy is activated.
Definition: snail.cpp:95
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:233
virtual bool can_break() const override
True if this badguy can break bricks or open bonusblocks in his current form.
Definition: snail.cpp:90
Base class for all the things that make up Levels&#39; Sectors.
Definition: game_object.hpp:46
virtual HitResponse collision_player(Player &player, const CollisionHit &hit) override
Called when the badguy collided with a player.
Definition: snail.cpp:212
Badguy "Snail" - a snail-like creature that can be flipped and tossed around at an angle...
Definition: snail.hpp:25
Base class for all dynamic/moving game objects.
Definition: moving_object.hpp:31
virtual void collision_solid(const CollisionHit &hit) override
Called when the badguy collided with solid ground.
Definition: snail.cpp:148
virtual HitResponse collision_badguy(BadGuy &badguy, const CollisionHit &hit) override
Called when the badguy collided with another badguy.
Definition: snail.cpp:190
Simple timer designed to be used in the update functions of objects.
Definition: timer.hpp:24
Definition: reader_mapping.hpp:31
virtual void grab(MovingObject &, const Vector &pos, Direction dir_) override
called each frame when the object has been grabbed.
Definition: snail.cpp:286
Definition: player.hpp:39
virtual void initialize() override
called immediately before the first call to initialize
Definition: snail.cpp:45
This class collects data about a collision.
Definition: collision_hit.hpp:44