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
23/** Badguy "Snail" - a snail-like creature that can be flipped and
24 tossed around at an angle */
25class Snail final :
26 public WalkingBadguy,
27 public Portable
28{
29public:
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
48protected:
49 virtual bool collision_squished(GameObject& object) override;
50
51 void be_normal(); /**< switch to state STATE_NORMAL */
52 void be_flat(); /**< switch to state STATE_FLAT */
53 void be_kicked(); /**< switch to state STATE_KICKED_DELAY */
54 void be_grabbed();
55
56private:
57 enum State {
58 STATE_NORMAL, /**< walking around */
59 STATE_FLAT, /**< flipped upside-down */
60 STATE_KICKED_DELAY, /**< short delay before being launched */
61 STATE_KICKED, /**< launched */
62 STATE_GRABBED /**< grabbed by tux */
63 };
64
65private:
66 State state;
67 Timer kicked_delay_timer; /**< wait time until switching from STATE_KICKED_DELAY to STATE_KICKED */
68 int squishcount;
69
70private:
71 Snail(const Snail&) = delete;
72 Snail& operator=(const Snail&) = delete;
73};
74
75#endif
76
77/* EOF */
78